Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.9% → 96.7%
Time: 9.5s
Alternatives: 12
Speedup: 2.6×

Specification

?
\[\begin{array}{l} \\ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (*
  (cos (- (/ (* K (+ m n)) 2.0) M))
  (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
	return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l):
	return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l)
	return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n))))))
end
function tmp = code(K, m, n, M, l)
	tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n)))));
end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\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 12 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: 76.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (*
  (cos (- (/ (* K (+ m n)) 2.0) M))
  (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
	return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l):
	return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l)
	return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n))))))
end
function tmp = code(K, m, n, M, l)
	tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n)))));
end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}

Alternative 1: 96.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}} \cdot \frac{1}{\frac{1}{\cos M}} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (*
  (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ n m) 2.0) M) 2.0)))
  (/ 1.0 (/ 1.0 (cos M)))))
double code(double K, double m, double n, double M, double l) {
	return exp(((fabs((n - m)) - l) - pow((((n + m) / 2.0) - M), 2.0))) * (1.0 / (1.0 / cos(M)));
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = exp(((abs((n - m)) - l) - ((((n + m) / 2.0d0) - m_1) ** 2.0d0))) * (1.0d0 / (1.0d0 / cos(m_1)))
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.exp(((Math.abs((n - m)) - l) - Math.pow((((n + m) / 2.0) - M), 2.0))) * (1.0 / (1.0 / Math.cos(M)));
}
def code(K, m, n, M, l):
	return math.exp(((math.fabs((n - m)) - l) - math.pow((((n + m) / 2.0) - M), 2.0))) * (1.0 / (1.0 / math.cos(M)))
function code(K, m, n, M, l)
	return Float64(exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(n + m) / 2.0) - M) ^ 2.0))) * Float64(1.0 / Float64(1.0 / cos(M))))
end
function tmp = code(K, m, n, M, l)
	tmp = exp(((abs((n - m)) - l) - ((((n + m) / 2.0) - M) ^ 2.0))) * (1.0 / (1.0 / cos(M)));
end
code[K_, m_, n_, M_, l_] := N[(N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(n + m), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 / N[(1.0 / N[Cos[M], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}} \cdot \frac{1}{\frac{1}{\cos M}}
\end{array}
Derivation
  1. Initial program 72.5%

    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in K around 0

    \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    2. associate-*r*N/A

      \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    5. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    6. lower-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    7. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    8. lower-+.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    9. sin-negN/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    10. lower-neg.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    11. lower-sin.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    12. cos-negN/A

      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    13. lower-cos.f6481.6

      \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  5. Applied rewrites81.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  6. Step-by-step derivation
    1. Applied rewrites59.0%

      \[\leadsto \frac{1}{\color{blue}{\frac{\left(-0.5 \cdot \left(\left(n + m\right) \cdot K\right)\right) \cdot \left(-\sin M\right) - \cos M}{{\left(\left(-0.5 \cdot \left(\left(n + m\right) \cdot K\right)\right) \cdot \left(-\sin M\right)\right)}^{2} - {\cos M}^{2}}}} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    2. Taylor expanded in K around 0

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\cos M}}} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. Applied rewrites95.9%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\cos M}}} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Final simplification95.9%

        \[\leadsto e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}} \cdot \frac{1}{\frac{1}{\cos M}} \]
      3. Add Preprocessing

      Alternative 2: 96.7% accurate, 1.1× speedup?

      \[\begin{array}{l} \\ e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M \end{array} \]
      (FPCore (K m n M l)
       :precision binary64
       (* (exp (- (fabs (- n m)) (+ (pow (fma 0.5 (+ n m) (- M)) 2.0) l))) (cos M)))
      double code(double K, double m, double n, double M, double l) {
      	return exp((fabs((n - m)) - (pow(fma(0.5, (n + m), -M), 2.0) + l))) * cos(M);
      }
      
      function code(K, m, n, M, l)
      	return Float64(exp(Float64(abs(Float64(n - m)) - Float64((fma(0.5, Float64(n + m), Float64(-M)) ^ 2.0) + l))) * cos(M))
      end
      
      code[K_, m_, n_, M_, l_] := N[(N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(0.5 * N[(n + m), $MachinePrecision] + (-M)), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M
      \end{array}
      
      Derivation
      1. Initial program 72.5%

        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Add Preprocessing
      3. Taylor expanded in K around 0

        \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)}} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
        2. lower-*.f64N/A

          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
      5. Applied rewrites95.9%

        \[\leadsto \color{blue}{e^{\left|m - n\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M} \]
      6. Final simplification95.9%

        \[\leadsto e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M \]
      7. Add Preprocessing

      Alternative 3: 92.1% accurate, 1.3× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(-M\right) \cdot M}\\ \mathbf{if}\;M \leq -9:\\ \;\;\;\;t\_0 \cdot \cos M\\ \mathbf{elif}\;M \leq 26.5:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right) \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;t\_0 \cdot 1\\ \end{array} \end{array} \]
      (FPCore (K m n M l)
       :precision binary64
       (let* ((t_0 (exp (* (- M) M))))
         (if (<= M -9.0)
           (* t_0 (cos M))
           (if (<= M 26.5)
             (*
              (fma (* (* (+ n m) M) K) 0.5 1.0)
              (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ n m) 2.0) M) 2.0))))
             (* t_0 1.0)))))
      double code(double K, double m, double n, double M, double l) {
      	double t_0 = exp((-M * M));
      	double tmp;
      	if (M <= -9.0) {
      		tmp = t_0 * cos(M);
      	} else if (M <= 26.5) {
      		tmp = fma((((n + m) * M) * K), 0.5, 1.0) * exp(((fabs((n - m)) - l) - pow((((n + m) / 2.0) - M), 2.0)));
      	} else {
      		tmp = t_0 * 1.0;
      	}
      	return tmp;
      }
      
      function code(K, m, n, M, l)
      	t_0 = exp(Float64(Float64(-M) * M))
      	tmp = 0.0
      	if (M <= -9.0)
      		tmp = Float64(t_0 * cos(M));
      	elseif (M <= 26.5)
      		tmp = Float64(fma(Float64(Float64(Float64(n + m) * M) * K), 0.5, 1.0) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(n + m) / 2.0) - M) ^ 2.0))));
      	else
      		tmp = Float64(t_0 * 1.0);
      	end
      	return tmp
      end
      
      code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -9.0], N[(t$95$0 * N[Cos[M], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 26.5], N[(N[(N[(N[(N[(n + m), $MachinePrecision] * M), $MachinePrecision] * K), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(n + m), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * 1.0), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := e^{\left(-M\right) \cdot M}\\
      \mathbf{if}\;M \leq -9:\\
      \;\;\;\;t\_0 \cdot \cos M\\
      
      \mathbf{elif}\;M \leq 26.5:\\
      \;\;\;\;\mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right) \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0 \cdot 1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if M < -9

        1. Initial program 78.6%

          \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. Add Preprocessing
        3. Taylor expanded in K around 0

          \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)}} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
          2. lower-*.f64N/A

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
        5. Applied rewrites99.9%

          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M} \]
        6. Taylor expanded in M around inf

          \[\leadsto e^{-1 \cdot {M}^{2}} \cdot \cos M \]
        7. Step-by-step derivation
          1. Applied rewrites98.3%

            \[\leadsto e^{\left(-M\right) \cdot M} \cdot \cos M \]

          if -9 < M < 26.5

          1. Initial program 68.0%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Add Preprocessing
          3. Taylor expanded in K around 0

            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate-*r*N/A

              \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            3. lower-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            4. lower-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            5. *-commutativeN/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            6. lower-*.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            7. +-commutativeN/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            8. lower-+.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            9. sin-negN/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            10. lower-neg.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            11. lower-sin.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            12. cos-negN/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            13. lower-cos.f6486.2

              \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          5. Applied rewrites86.2%

            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          6. Taylor expanded in M around 0

            \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          7. Step-by-step derivation
            1. Applied rewrites86.2%

              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]

            if 26.5 < M

            1. Initial program 75.0%

              \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in K around 0

              \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            4. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. associate-*r*N/A

                \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              3. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              4. lower-*.f64N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              5. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              6. lower-*.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              7. +-commutativeN/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              8. lower-+.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              9. sin-negN/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              10. lower-neg.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              11. lower-sin.f64N/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              12. cos-negN/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              13. lower-cos.f6476.4

                \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            5. Applied rewrites76.4%

              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            6. Taylor expanded in M around 0

              \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            7. Step-by-step derivation
              1. Applied rewrites43.1%

                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. Taylor expanded in M around inf

                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
              3. Step-by-step derivation
                1. mul-1-negN/A

                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                2. unpow2N/A

                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                3. distribute-lft-neg-inN/A

                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                4. lower-*.f64N/A

                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                5. lower-neg.f6441.7

                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
              4. Applied rewrites41.7%

                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
              5. Taylor expanded in K around 0

                \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
              6. Step-by-step derivation
                1. Applied rewrites98.6%

                  \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
              7. Recombined 3 regimes into one program.
              8. Final simplification92.6%

                \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -9:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{elif}\;M \leq 26.5:\\ \;\;\;\;\mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right) \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
              9. Add Preprocessing

              Alternative 4: 96.0% accurate, 1.4× speedup?

              \[\begin{array}{l} \\ \frac{1}{\mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, -0.5, 1\right)} \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}} \end{array} \]
              (FPCore (K m n M l)
               :precision binary64
               (*
                (/ 1.0 (fma (* (* (+ n m) M) K) -0.5 1.0))
                (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ n m) 2.0) M) 2.0)))))
              double code(double K, double m, double n, double M, double l) {
              	return (1.0 / fma((((n + m) * M) * K), -0.5, 1.0)) * exp(((fabs((n - m)) - l) - pow((((n + m) / 2.0) - M), 2.0)));
              }
              
              function code(K, m, n, M, l)
              	return Float64(Float64(1.0 / fma(Float64(Float64(Float64(n + m) * M) * K), -0.5, 1.0)) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(n + m) / 2.0) - M) ^ 2.0))))
              end
              
              code[K_, m_, n_, M_, l_] := N[(N[(1.0 / N[(N[(N[(N[(n + m), $MachinePrecision] * M), $MachinePrecision] * K), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(n + m), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \frac{1}{\mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, -0.5, 1\right)} \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}}
              \end{array}
              
              Derivation
              1. Initial program 72.5%

                \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in K around 0

                \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                2. associate-*r*N/A

                  \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                3. lower-fma.f64N/A

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                4. lower-*.f64N/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                5. *-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                6. lower-*.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                7. +-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                8. lower-+.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                9. sin-negN/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                10. lower-neg.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                11. lower-sin.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                12. cos-negN/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                13. lower-cos.f6481.6

                  \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              5. Applied rewrites81.6%

                \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              6. Step-by-step derivation
                1. Applied rewrites59.0%

                  \[\leadsto \frac{1}{\color{blue}{\frac{\left(-0.5 \cdot \left(\left(n + m\right) \cdot K\right)\right) \cdot \left(-\sin M\right) - \cos M}{{\left(\left(-0.5 \cdot \left(\left(n + m\right) \cdot K\right)\right) \cdot \left(-\sin M\right)\right)}^{2} - {\cos M}^{2}}}} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                2. Taylor expanded in M around 0

                  \[\leadsto \frac{1}{1 + \color{blue}{\frac{-1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                3. Step-by-step derivation
                  1. Applied rewrites94.9%

                    \[\leadsto \frac{1}{\mathsf{fma}\left(\left(\left(m + n\right) \cdot M\right) \cdot K, \color{blue}{-0.5}, 1\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                  2. Final simplification94.9%

                    \[\leadsto \frac{1}{\mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, -0.5, 1\right)} \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{n + m}{2} - M\right)}^{2}} \]
                  3. Add Preprocessing

                  Alternative 5: 80.9% accurate, 1.6× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|n - m\right| - \ell\\ t_1 := e^{\left(-M\right) \cdot M}\\ t_2 := \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{if}\;M \leq -7.6:\\ \;\;\;\;t\_1 \cdot \cos M\\ \mathbf{elif}\;M \leq -2 \cdot 10^{-292}:\\ \;\;\;\;e^{t\_0 - 0.25 \cdot \left(m \cdot m\right)} \cdot t\_2\\ \mathbf{elif}\;M \leq 26.5:\\ \;\;\;\;e^{t\_0 - \left(n \cdot n\right) \cdot 0.25} \cdot t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_1 \cdot 1\\ \end{array} \end{array} \]
                  (FPCore (K m n M l)
                   :precision binary64
                   (let* ((t_0 (- (fabs (- n m)) l))
                          (t_1 (exp (* (- M) M)))
                          (t_2 (fma (* (* (+ n m) M) K) 0.5 1.0)))
                     (if (<= M -7.6)
                       (* t_1 (cos M))
                       (if (<= M -2e-292)
                         (* (exp (- t_0 (* 0.25 (* m m)))) t_2)
                         (if (<= M 26.5) (* (exp (- t_0 (* (* n n) 0.25))) t_2) (* t_1 1.0))))))
                  double code(double K, double m, double n, double M, double l) {
                  	double t_0 = fabs((n - m)) - l;
                  	double t_1 = exp((-M * M));
                  	double t_2 = fma((((n + m) * M) * K), 0.5, 1.0);
                  	double tmp;
                  	if (M <= -7.6) {
                  		tmp = t_1 * cos(M);
                  	} else if (M <= -2e-292) {
                  		tmp = exp((t_0 - (0.25 * (m * m)))) * t_2;
                  	} else if (M <= 26.5) {
                  		tmp = exp((t_0 - ((n * n) * 0.25))) * t_2;
                  	} else {
                  		tmp = t_1 * 1.0;
                  	}
                  	return tmp;
                  }
                  
                  function code(K, m, n, M, l)
                  	t_0 = Float64(abs(Float64(n - m)) - l)
                  	t_1 = exp(Float64(Float64(-M) * M))
                  	t_2 = fma(Float64(Float64(Float64(n + m) * M) * K), 0.5, 1.0)
                  	tmp = 0.0
                  	if (M <= -7.6)
                  		tmp = Float64(t_1 * cos(M));
                  	elseif (M <= -2e-292)
                  		tmp = Float64(exp(Float64(t_0 - Float64(0.25 * Float64(m * m)))) * t_2);
                  	elseif (M <= 26.5)
                  		tmp = Float64(exp(Float64(t_0 - Float64(Float64(n * n) * 0.25))) * t_2);
                  	else
                  		tmp = Float64(t_1 * 1.0);
                  	end
                  	return tmp
                  end
                  
                  code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(n + m), $MachinePrecision] * M), $MachinePrecision] * K), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]}, If[LessEqual[M, -7.6], N[(t$95$1 * N[Cos[M], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, -2e-292], N[(N[Exp[N[(t$95$0 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[M, 26.5], N[(N[Exp[N[(t$95$0 - N[(N[(n * n), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], N[(t$95$1 * 1.0), $MachinePrecision]]]]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \left|n - m\right| - \ell\\
                  t_1 := e^{\left(-M\right) \cdot M}\\
                  t_2 := \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\
                  \mathbf{if}\;M \leq -7.6:\\
                  \;\;\;\;t\_1 \cdot \cos M\\
                  
                  \mathbf{elif}\;M \leq -2 \cdot 10^{-292}:\\
                  \;\;\;\;e^{t\_0 - 0.25 \cdot \left(m \cdot m\right)} \cdot t\_2\\
                  
                  \mathbf{elif}\;M \leq 26.5:\\
                  \;\;\;\;e^{t\_0 - \left(n \cdot n\right) \cdot 0.25} \cdot t\_2\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_1 \cdot 1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 4 regimes
                  2. if M < -7.5999999999999996

                    1. Initial program 78.6%

                      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                    2. Add Preprocessing
                    3. Taylor expanded in K around 0

                      \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)}} \]
                    4. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                      2. lower-*.f64N/A

                        \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                    5. Applied rewrites99.9%

                      \[\leadsto \color{blue}{e^{\left|m - n\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M} \]
                    6. Taylor expanded in M around inf

                      \[\leadsto e^{-1 \cdot {M}^{2}} \cdot \cos M \]
                    7. Step-by-step derivation
                      1. Applied rewrites98.3%

                        \[\leadsto e^{\left(-M\right) \cdot M} \cdot \cos M \]

                      if -7.5999999999999996 < M < -2.0000000000000001e-292

                      1. Initial program 70.8%

                        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                      2. Add Preprocessing
                      3. Taylor expanded in K around 0

                        \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                      4. Step-by-step derivation
                        1. +-commutativeN/A

                          \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        2. associate-*r*N/A

                          \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        3. lower-fma.f64N/A

                          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        4. lower-*.f64N/A

                          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        5. *-commutativeN/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        6. lower-*.f64N/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        7. +-commutativeN/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        8. lower-+.f64N/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        9. sin-negN/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        10. lower-neg.f64N/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        11. lower-sin.f64N/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        12. cos-negN/A

                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        13. lower-cos.f6489.2

                          \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                      5. Applied rewrites89.2%

                        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                      6. Taylor expanded in M around 0

                        \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                      7. Step-by-step derivation
                        1. Applied rewrites89.2%

                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        2. Taylor expanded in m around inf

                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\frac{1}{4} \cdot {m}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        3. Step-by-step derivation
                          1. *-commutativeN/A

                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{m}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          2. lower-*.f64N/A

                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{m}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          3. unpow2N/A

                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot \frac{1}{4}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          4. lower-*.f6463.0

                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
                        4. Applied rewrites63.0%

                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right) \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]

                        if -2.0000000000000001e-292 < M < 26.5

                        1. Initial program 65.4%

                          \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        2. Add Preprocessing
                        3. Taylor expanded in K around 0

                          \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        4. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          2. associate-*r*N/A

                            \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          3. lower-fma.f64N/A

                            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          4. lower-*.f64N/A

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          5. *-commutativeN/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          6. lower-*.f64N/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          7. +-commutativeN/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          8. lower-+.f64N/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          9. sin-negN/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          10. lower-neg.f64N/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          11. lower-sin.f64N/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          12. cos-negN/A

                            \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          13. lower-cos.f6483.3

                            \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        5. Applied rewrites83.3%

                          \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        6. Taylor expanded in M around 0

                          \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        7. Step-by-step derivation
                          1. Applied rewrites83.3%

                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          2. Taylor expanded in n around inf

                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\frac{1}{4} \cdot {n}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          3. Step-by-step derivation
                            1. *-commutativeN/A

                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{n}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            2. lower-*.f64N/A

                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{n}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            3. unpow2N/A

                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right)} \cdot \frac{1}{4}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            4. lower-*.f6458.3

                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
                          4. Applied rewrites58.3%

                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right) \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]

                          if 26.5 < M

                          1. Initial program 75.0%

                            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          2. Add Preprocessing
                          3. Taylor expanded in K around 0

                            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          4. Step-by-step derivation
                            1. +-commutativeN/A

                              \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            2. associate-*r*N/A

                              \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            3. lower-fma.f64N/A

                              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            4. lower-*.f64N/A

                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            5. *-commutativeN/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            6. lower-*.f64N/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            7. +-commutativeN/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            8. lower-+.f64N/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            9. sin-negN/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            10. lower-neg.f64N/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            11. lower-sin.f64N/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            12. cos-negN/A

                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            13. lower-cos.f6476.4

                              \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          5. Applied rewrites76.4%

                            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          6. Taylor expanded in M around 0

                            \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          7. Step-by-step derivation
                            1. Applied rewrites43.1%

                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            2. Taylor expanded in M around inf

                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                            3. Step-by-step derivation
                              1. mul-1-negN/A

                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                              2. unpow2N/A

                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                              3. distribute-lft-neg-inN/A

                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                              4. lower-*.f64N/A

                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                              5. lower-neg.f6441.7

                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                            4. Applied rewrites41.7%

                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                            5. Taylor expanded in K around 0

                              \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                            6. Step-by-step derivation
                              1. Applied rewrites98.6%

                                \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                            7. Recombined 4 regimes into one program.
                            8. Final simplification80.3%

                              \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -7.6:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{elif}\;M \leq -2 \cdot 10^{-292}:\\ \;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{elif}\;M \leq 26.5:\\ \;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - \left(n \cdot n\right) \cdot 0.25} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
                            9. Add Preprocessing

                            Alternative 6: 80.7% accurate, 2.2× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|n - m\right| - \ell\\ t_1 := e^{\left(-M\right) \cdot M} \cdot 1\\ t_2 := \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{if}\;M \leq -9:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq -1.15 \cdot 10^{-271}:\\ \;\;\;\;e^{t\_0 - 0.25 \cdot \left(m \cdot m\right)} \cdot t\_2\\ \mathbf{elif}\;M \leq 26.5:\\ \;\;\;\;e^{t\_0 - \left(n \cdot n\right) \cdot 0.25} \cdot t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                            (FPCore (K m n M l)
                             :precision binary64
                             (let* ((t_0 (- (fabs (- n m)) l))
                                    (t_1 (* (exp (* (- M) M)) 1.0))
                                    (t_2 (fma (* (* (+ n m) M) K) 0.5 1.0)))
                               (if (<= M -9.0)
                                 t_1
                                 (if (<= M -1.15e-271)
                                   (* (exp (- t_0 (* 0.25 (* m m)))) t_2)
                                   (if (<= M 26.5) (* (exp (- t_0 (* (* n n) 0.25))) t_2) t_1)))))
                            double code(double K, double m, double n, double M, double l) {
                            	double t_0 = fabs((n - m)) - l;
                            	double t_1 = exp((-M * M)) * 1.0;
                            	double t_2 = fma((((n + m) * M) * K), 0.5, 1.0);
                            	double tmp;
                            	if (M <= -9.0) {
                            		tmp = t_1;
                            	} else if (M <= -1.15e-271) {
                            		tmp = exp((t_0 - (0.25 * (m * m)))) * t_2;
                            	} else if (M <= 26.5) {
                            		tmp = exp((t_0 - ((n * n) * 0.25))) * t_2;
                            	} else {
                            		tmp = t_1;
                            	}
                            	return tmp;
                            }
                            
                            function code(K, m, n, M, l)
                            	t_0 = Float64(abs(Float64(n - m)) - l)
                            	t_1 = Float64(exp(Float64(Float64(-M) * M)) * 1.0)
                            	t_2 = fma(Float64(Float64(Float64(n + m) * M) * K), 0.5, 1.0)
                            	tmp = 0.0
                            	if (M <= -9.0)
                            		tmp = t_1;
                            	elseif (M <= -1.15e-271)
                            		tmp = Float64(exp(Float64(t_0 - Float64(0.25 * Float64(m * m)))) * t_2);
                            	elseif (M <= 26.5)
                            		tmp = Float64(exp(Float64(t_0 - Float64(Float64(n * n) * 0.25))) * t_2);
                            	else
                            		tmp = t_1;
                            	end
                            	return tmp
                            end
                            
                            code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(n + m), $MachinePrecision] * M), $MachinePrecision] * K), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]}, If[LessEqual[M, -9.0], t$95$1, If[LessEqual[M, -1.15e-271], N[(N[Exp[N[(t$95$0 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[M, 26.5], N[(N[Exp[N[(t$95$0 - N[(N[(n * n), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], t$95$1]]]]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_0 := \left|n - m\right| - \ell\\
                            t_1 := e^{\left(-M\right) \cdot M} \cdot 1\\
                            t_2 := \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\
                            \mathbf{if}\;M \leq -9:\\
                            \;\;\;\;t\_1\\
                            
                            \mathbf{elif}\;M \leq -1.15 \cdot 10^{-271}:\\
                            \;\;\;\;e^{t\_0 - 0.25 \cdot \left(m \cdot m\right)} \cdot t\_2\\
                            
                            \mathbf{elif}\;M \leq 26.5:\\
                            \;\;\;\;e^{t\_0 - \left(n \cdot n\right) \cdot 0.25} \cdot t\_2\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;t\_1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 3 regimes
                            2. if M < -9 or 26.5 < M

                              1. Initial program 76.6%

                                \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                              2. Add Preprocessing
                              3. Taylor expanded in K around 0

                                \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                              4. Step-by-step derivation
                                1. +-commutativeN/A

                                  \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                2. associate-*r*N/A

                                  \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                3. lower-fma.f64N/A

                                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                4. lower-*.f64N/A

                                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                5. *-commutativeN/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                6. lower-*.f64N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                7. +-commutativeN/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                8. lower-+.f64N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                9. sin-negN/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                10. lower-neg.f64N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                11. lower-sin.f64N/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                12. cos-negN/A

                                  \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                13. lower-cos.f6477.4

                                  \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                              5. Applied rewrites77.4%

                                \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                              6. Taylor expanded in M around 0

                                \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                              7. Step-by-step derivation
                                1. Applied rewrites41.4%

                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                2. Taylor expanded in M around inf

                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                                3. Step-by-step derivation
                                  1. mul-1-negN/A

                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                                  2. unpow2N/A

                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                                  3. distribute-lft-neg-inN/A

                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                  4. lower-*.f64N/A

                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                  5. lower-neg.f6440.6

                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                                4. Applied rewrites40.6%

                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                                5. Taylor expanded in K around 0

                                  \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                6. Step-by-step derivation
                                  1. Applied rewrites97.8%

                                    \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]

                                  if -9 < M < -1.15000000000000004e-271

                                  1. Initial program 72.8%

                                    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                  2. Add Preprocessing
                                  3. Taylor expanded in K around 0

                                    \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                  4. Step-by-step derivation
                                    1. +-commutativeN/A

                                      \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    2. associate-*r*N/A

                                      \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    3. lower-fma.f64N/A

                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    4. lower-*.f64N/A

                                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    5. *-commutativeN/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    6. lower-*.f64N/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    7. +-commutativeN/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    8. lower-+.f64N/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    9. sin-negN/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    10. lower-neg.f64N/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    11. lower-sin.f64N/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    12. cos-negN/A

                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    13. lower-cos.f6490.2

                                      \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                  5. Applied rewrites90.2%

                                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                  6. Taylor expanded in M around 0

                                    \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                  7. Step-by-step derivation
                                    1. Applied rewrites90.2%

                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    2. Taylor expanded in m around inf

                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\frac{1}{4} \cdot {m}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    3. Step-by-step derivation
                                      1. *-commutativeN/A

                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{m}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      2. lower-*.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{m}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      3. unpow2N/A

                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot \frac{1}{4}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      4. lower-*.f6463.1

                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    4. Applied rewrites63.1%

                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right) \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]

                                    if -1.15000000000000004e-271 < M < 26.5

                                    1. Initial program 63.7%

                                      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    2. Add Preprocessing
                                    3. Taylor expanded in K around 0

                                      \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    4. Step-by-step derivation
                                      1. +-commutativeN/A

                                        \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      2. associate-*r*N/A

                                        \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      3. lower-fma.f64N/A

                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      4. lower-*.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      5. *-commutativeN/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      6. lower-*.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      7. +-commutativeN/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      8. lower-+.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      9. sin-negN/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      10. lower-neg.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      11. lower-sin.f64N/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      12. cos-negN/A

                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      13. lower-cos.f6482.6

                                        \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    5. Applied rewrites82.6%

                                      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    6. Taylor expanded in M around 0

                                      \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites82.6%

                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      2. Taylor expanded in n around inf

                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\frac{1}{4} \cdot {n}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      3. Step-by-step derivation
                                        1. *-commutativeN/A

                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{n}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        2. lower-*.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{n}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        3. unpow2N/A

                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right)} \cdot \frac{1}{4}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        4. lower-*.f6458.4

                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      4. Applied rewrites58.4%

                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right) \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                    8. Recombined 3 regimes into one program.
                                    9. Final simplification79.9%

                                      \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -9:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{elif}\;M \leq -1.15 \cdot 10^{-271}:\\ \;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{elif}\;M \leq 26.5:\\ \;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - \left(n \cdot n\right) \cdot 0.25} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
                                    10. Add Preprocessing

                                    Alternative 7: 78.3% accurate, 2.3× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{if}\;M \leq -9:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq -7.5 \cdot 10^{-268}:\\ \;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                    (FPCore (K m n M l)
                                     :precision binary64
                                     (let* ((t_0 (* (exp (* (- M) M)) 1.0)))
                                       (if (<= M -9.0)
                                         t_0
                                         (if (<= M -7.5e-268)
                                           (*
                                            (exp (- (- (fabs (- n m)) l) (* 0.25 (* m m))))
                                            (fma (* (* (+ n m) M) K) 0.5 1.0))
                                           (if (<= M 3.35e+16)
                                             (* (fma (* M M) -0.5 1.0) (exp (* -0.25 (* n n))))
                                             t_0)))))
                                    double code(double K, double m, double n, double M, double l) {
                                    	double t_0 = exp((-M * M)) * 1.0;
                                    	double tmp;
                                    	if (M <= -9.0) {
                                    		tmp = t_0;
                                    	} else if (M <= -7.5e-268) {
                                    		tmp = exp(((fabs((n - m)) - l) - (0.25 * (m * m)))) * fma((((n + m) * M) * K), 0.5, 1.0);
                                    	} else if (M <= 3.35e+16) {
                                    		tmp = fma((M * M), -0.5, 1.0) * exp((-0.25 * (n * n)));
                                    	} else {
                                    		tmp = t_0;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    function code(K, m, n, M, l)
                                    	t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0)
                                    	tmp = 0.0
                                    	if (M <= -9.0)
                                    		tmp = t_0;
                                    	elseif (M <= -7.5e-268)
                                    		tmp = Float64(exp(Float64(Float64(abs(Float64(n - m)) - l) - Float64(0.25 * Float64(m * m)))) * fma(Float64(Float64(Float64(n + m) * M) * K), 0.5, 1.0));
                                    	elseif (M <= 3.35e+16)
                                    		tmp = Float64(fma(Float64(M * M), -0.5, 1.0) * exp(Float64(-0.25 * Float64(n * n))));
                                    	else
                                    		tmp = t_0;
                                    	end
                                    	return tmp
                                    end
                                    
                                    code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -9.0], t$95$0, If[LessEqual[M, -7.5e-268], N[(N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(N[(n + m), $MachinePrecision] * M), $MachinePrecision] * K), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 3.35e+16], N[(N[(N[(M * M), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
                                    \mathbf{if}\;M \leq -9:\\
                                    \;\;\;\;t\_0\\
                                    
                                    \mathbf{elif}\;M \leq -7.5 \cdot 10^{-268}:\\
                                    \;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\
                                    
                                    \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\
                                    \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;t\_0\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 3 regimes
                                    2. if M < -9 or 3.35e16 < M

                                      1. Initial program 77.8%

                                        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      2. Add Preprocessing
                                      3. Taylor expanded in K around 0

                                        \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      4. Step-by-step derivation
                                        1. +-commutativeN/A

                                          \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        2. associate-*r*N/A

                                          \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        3. lower-fma.f64N/A

                                          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        4. lower-*.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        5. *-commutativeN/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        6. lower-*.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        7. +-commutativeN/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        8. lower-+.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        9. sin-negN/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        10. lower-neg.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        11. lower-sin.f64N/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        12. cos-negN/A

                                          \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        13. lower-cos.f6477.8

                                          \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      5. Applied rewrites77.8%

                                        \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      6. Taylor expanded in M around 0

                                        \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                      7. Step-by-step derivation
                                        1. Applied rewrites41.2%

                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                        2. Taylor expanded in M around inf

                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                                        3. Step-by-step derivation
                                          1. mul-1-negN/A

                                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                                          2. unpow2N/A

                                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                                          3. distribute-lft-neg-inN/A

                                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                          4. lower-*.f64N/A

                                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                          5. lower-neg.f6441.2

                                            \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                                        4. Applied rewrites41.2%

                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                                        5. Taylor expanded in K around 0

                                          \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                        6. Step-by-step derivation
                                          1. Applied rewrites98.5%

                                            \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]

                                          if -9 < M < -7.4999999999999999e-268

                                          1. Initial program 74.5%

                                            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                          2. Add Preprocessing
                                          3. Taylor expanded in K around 0

                                            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                          4. Step-by-step derivation
                                            1. +-commutativeN/A

                                              \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            2. associate-*r*N/A

                                              \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            3. lower-fma.f64N/A

                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            4. lower-*.f64N/A

                                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            5. *-commutativeN/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            6. lower-*.f64N/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            7. +-commutativeN/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            8. lower-+.f64N/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            9. sin-negN/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            10. lower-neg.f64N/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            11. lower-sin.f64N/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            12. cos-negN/A

                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            13. lower-cos.f6489.5

                                              \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                          5. Applied rewrites89.5%

                                            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                          6. Taylor expanded in M around 0

                                            \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                          7. Step-by-step derivation
                                            1. Applied rewrites89.5%

                                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            2. Taylor expanded in m around inf

                                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\frac{1}{4} \cdot {m}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            3. Step-by-step derivation
                                              1. *-commutativeN/A

                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{m}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{{m}^{2} \cdot \frac{1}{4}}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                              3. unpow2N/A

                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot \frac{1}{4}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                              4. lower-*.f6462.2

                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            4. Applied rewrites62.2%

                                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\left(-\color{blue}{\left(m \cdot m\right) \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]

                                            if -7.4999999999999999e-268 < M < 3.35e16

                                            1. Initial program 61.2%

                                              \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                            2. Add Preprocessing
                                            3. Taylor expanded in K around 0

                                              \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)}} \]
                                            4. Step-by-step derivation
                                              1. *-commutativeN/A

                                                \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                                              2. lower-*.f64N/A

                                                \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                                            5. Applied rewrites88.9%

                                              \[\leadsto \color{blue}{e^{\left|m - n\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M} \]
                                            6. Taylor expanded in n around inf

                                              \[\leadsto e^{\frac{-1}{4} \cdot {n}^{2}} \cdot \cos M \]
                                            7. Step-by-step derivation
                                              1. Applied rewrites53.5%

                                                \[\leadsto e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M \]
                                              2. Taylor expanded in M around 0

                                                \[\leadsto e^{\left(n \cdot n\right) \cdot \frac{-1}{4}} \cdot \left(1 + \color{blue}{\frac{-1}{2} \cdot {M}^{2}}\right) \]
                                              3. Step-by-step derivation
                                                1. Applied rewrites53.5%

                                                  \[\leadsto e^{\left(n \cdot n\right) \cdot -0.25} \cdot \mathsf{fma}\left(M \cdot M, \color{blue}{-0.5}, 1\right) \]
                                              4. Recombined 3 regimes into one program.
                                              5. Final simplification78.3%

                                                \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -9:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{elif}\;M \leq -7.5 \cdot 10^{-268}:\\ \;\;\;\;e^{\left(\left|n - m\right| - \ell\right) - 0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
                                              6. Add Preprocessing

                                              Alternative 8: 75.4% accurate, 2.4× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{if}\;M \leq -1.35 \cdot 10^{-15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq -7.5 \cdot 10^{-268}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                              (FPCore (K m n M l)
                                               :precision binary64
                                               (let* ((t_0 (* (exp (* (- M) M)) 1.0)))
                                                 (if (<= M -1.35e-15)
                                                   t_0
                                                   (if (<= M -7.5e-268)
                                                     (* (exp (* -0.25 (* m m))) (fma (* (* (+ n m) M) K) 0.5 1.0))
                                                     (if (<= M 3.35e+16)
                                                       (* (fma (* M M) -0.5 1.0) (exp (* -0.25 (* n n))))
                                                       t_0)))))
                                              double code(double K, double m, double n, double M, double l) {
                                              	double t_0 = exp((-M * M)) * 1.0;
                                              	double tmp;
                                              	if (M <= -1.35e-15) {
                                              		tmp = t_0;
                                              	} else if (M <= -7.5e-268) {
                                              		tmp = exp((-0.25 * (m * m))) * fma((((n + m) * M) * K), 0.5, 1.0);
                                              	} else if (M <= 3.35e+16) {
                                              		tmp = fma((M * M), -0.5, 1.0) * exp((-0.25 * (n * n)));
                                              	} else {
                                              		tmp = t_0;
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(K, m, n, M, l)
                                              	t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0)
                                              	tmp = 0.0
                                              	if (M <= -1.35e-15)
                                              		tmp = t_0;
                                              	elseif (M <= -7.5e-268)
                                              		tmp = Float64(exp(Float64(-0.25 * Float64(m * m))) * fma(Float64(Float64(Float64(n + m) * M) * K), 0.5, 1.0));
                                              	elseif (M <= 3.35e+16)
                                              		tmp = Float64(fma(Float64(M * M), -0.5, 1.0) * exp(Float64(-0.25 * Float64(n * n))));
                                              	else
                                              		tmp = t_0;
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -1.35e-15], t$95$0, If[LessEqual[M, -7.5e-268], N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(N[(n + m), $MachinePrecision] * M), $MachinePrecision] * K), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 3.35e+16], N[(N[(N[(M * M), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
                                              \mathbf{if}\;M \leq -1.35 \cdot 10^{-15}:\\
                                              \;\;\;\;t\_0\\
                                              
                                              \mathbf{elif}\;M \leq -7.5 \cdot 10^{-268}:\\
                                              \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\
                                              
                                              \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\
                                              \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;t\_0\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 3 regimes
                                              2. if M < -1.35000000000000005e-15 or 3.35e16 < M

                                                1. Initial program 77.4%

                                                  \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                2. Add Preprocessing
                                                3. Taylor expanded in K around 0

                                                  \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                4. Step-by-step derivation
                                                  1. +-commutativeN/A

                                                    \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  2. associate-*r*N/A

                                                    \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  3. lower-fma.f64N/A

                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  4. lower-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  5. *-commutativeN/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  6. lower-*.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  7. +-commutativeN/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  8. lower-+.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  9. sin-negN/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  10. lower-neg.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  11. lower-sin.f64N/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  12. cos-negN/A

                                                    \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  13. lower-cos.f6477.4

                                                    \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                5. Applied rewrites77.4%

                                                  \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                6. Taylor expanded in M around 0

                                                  \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites41.4%

                                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                  2. Taylor expanded in M around inf

                                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                                                  3. Step-by-step derivation
                                                    1. mul-1-negN/A

                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                                                    2. unpow2N/A

                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                                                    3. distribute-lft-neg-inN/A

                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                    4. lower-*.f64N/A

                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                    5. lower-neg.f6440.7

                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                                                  4. Applied rewrites40.7%

                                                    \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                                                  5. Taylor expanded in K around 0

                                                    \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                                  6. Step-by-step derivation
                                                    1. Applied rewrites97.1%

                                                      \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]

                                                    if -1.35000000000000005e-15 < M < -7.4999999999999999e-268

                                                    1. Initial program 75.4%

                                                      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                    2. Add Preprocessing
                                                    3. Taylor expanded in K around 0

                                                      \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                    4. Step-by-step derivation
                                                      1. +-commutativeN/A

                                                        \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      2. associate-*r*N/A

                                                        \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      3. lower-fma.f64N/A

                                                        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      4. lower-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      5. *-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      6. lower-*.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      7. +-commutativeN/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      8. lower-+.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      9. sin-negN/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      10. lower-neg.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      11. lower-sin.f64N/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      12. cos-negN/A

                                                        \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      13. lower-cos.f6491.0

                                                        \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                    5. Applied rewrites91.0%

                                                      \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                    6. Taylor expanded in M around 0

                                                      \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                    7. Step-by-step derivation
                                                      1. Applied rewrites91.0%

                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      2. Taylor expanded in m around inf

                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\frac{-1}{4} \cdot {m}^{2}}} \]
                                                      3. Step-by-step derivation
                                                        1. *-commutativeN/A

                                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{{m}^{2} \cdot \frac{-1}{4}}} \]
                                                        2. lower-*.f64N/A

                                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{{m}^{2} \cdot \frac{-1}{4}}} \]
                                                        3. unpow2N/A

                                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
                                                        4. lower-*.f6449.8

                                                          \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
                                                      4. Applied rewrites49.8%

                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(m \cdot m\right) \cdot -0.25}} \]

                                                      if -7.4999999999999999e-268 < M < 3.35e16

                                                      1. Initial program 61.2%

                                                        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                      2. Add Preprocessing
                                                      3. Taylor expanded in K around 0

                                                        \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)}} \]
                                                      4. Step-by-step derivation
                                                        1. *-commutativeN/A

                                                          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                                                        2. lower-*.f64N/A

                                                          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                                                      5. Applied rewrites88.9%

                                                        \[\leadsto \color{blue}{e^{\left|m - n\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M} \]
                                                      6. Taylor expanded in n around inf

                                                        \[\leadsto e^{\frac{-1}{4} \cdot {n}^{2}} \cdot \cos M \]
                                                      7. Step-by-step derivation
                                                        1. Applied rewrites53.5%

                                                          \[\leadsto e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M \]
                                                        2. Taylor expanded in M around 0

                                                          \[\leadsto e^{\left(n \cdot n\right) \cdot \frac{-1}{4}} \cdot \left(1 + \color{blue}{\frac{-1}{2} \cdot {M}^{2}}\right) \]
                                                        3. Step-by-step derivation
                                                          1. Applied rewrites53.5%

                                                            \[\leadsto e^{\left(n \cdot n\right) \cdot -0.25} \cdot \mathsf{fma}\left(M \cdot M, \color{blue}{-0.5}, 1\right) \]
                                                        4. Recombined 3 regimes into one program.
                                                        5. Final simplification75.4%

                                                          \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -1.35 \cdot 10^{-15}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{elif}\;M \leq -7.5 \cdot 10^{-268}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \mathsf{fma}\left(\left(\left(n + m\right) \cdot M\right) \cdot K, 0.5, 1\right)\\ \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
                                                        6. Add Preprocessing

                                                        Alternative 9: 77.1% accurate, 2.6× speedup?

                                                        \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{if}\;M \leq -27:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                                        (FPCore (K m n M l)
                                                         :precision binary64
                                                         (let* ((t_0 (* (exp (* (- M) M)) 1.0)))
                                                           (if (<= M -27.0)
                                                             t_0
                                                             (if (<= M 3.35e+16)
                                                               (* (fma (* M M) -0.5 1.0) (exp (* -0.25 (* n n))))
                                                               t_0))))
                                                        double code(double K, double m, double n, double M, double l) {
                                                        	double t_0 = exp((-M * M)) * 1.0;
                                                        	double tmp;
                                                        	if (M <= -27.0) {
                                                        		tmp = t_0;
                                                        	} else if (M <= 3.35e+16) {
                                                        		tmp = fma((M * M), -0.5, 1.0) * exp((-0.25 * (n * n)));
                                                        	} else {
                                                        		tmp = t_0;
                                                        	}
                                                        	return tmp;
                                                        }
                                                        
                                                        function code(K, m, n, M, l)
                                                        	t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0)
                                                        	tmp = 0.0
                                                        	if (M <= -27.0)
                                                        		tmp = t_0;
                                                        	elseif (M <= 3.35e+16)
                                                        		tmp = Float64(fma(Float64(M * M), -0.5, 1.0) * exp(Float64(-0.25 * Float64(n * n))));
                                                        	else
                                                        		tmp = t_0;
                                                        	end
                                                        	return tmp
                                                        end
                                                        
                                                        code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -27.0], t$95$0, If[LessEqual[M, 3.35e+16], N[(N[(N[(M * M), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
                                                        
                                                        \begin{array}{l}
                                                        
                                                        \\
                                                        \begin{array}{l}
                                                        t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
                                                        \mathbf{if}\;M \leq -27:\\
                                                        \;\;\;\;t\_0\\
                                                        
                                                        \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\
                                                        \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\
                                                        
                                                        \mathbf{else}:\\
                                                        \;\;\;\;t\_0\\
                                                        
                                                        
                                                        \end{array}
                                                        \end{array}
                                                        
                                                        Derivation
                                                        1. Split input into 2 regimes
                                                        2. if M < -27 or 3.35e16 < M

                                                          1. Initial program 77.7%

                                                            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                          2. Add Preprocessing
                                                          3. Taylor expanded in K around 0

                                                            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                          4. Step-by-step derivation
                                                            1. +-commutativeN/A

                                                              \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            2. associate-*r*N/A

                                                              \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            3. lower-fma.f64N/A

                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            4. lower-*.f64N/A

                                                              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            5. *-commutativeN/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            6. lower-*.f64N/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            7. +-commutativeN/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            8. lower-+.f64N/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            9. sin-negN/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            10. lower-neg.f64N/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            11. lower-sin.f64N/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            12. cos-negN/A

                                                              \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            13. lower-cos.f6477.7

                                                              \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                          5. Applied rewrites77.7%

                                                            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                          6. Taylor expanded in M around 0

                                                            \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                          7. Step-by-step derivation
                                                            1. Applied rewrites41.5%

                                                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                            2. Taylor expanded in M around inf

                                                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                                                            3. Step-by-step derivation
                                                              1. mul-1-negN/A

                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                                                              2. unpow2N/A

                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                                                              3. distribute-lft-neg-inN/A

                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                              4. lower-*.f64N/A

                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                              5. lower-neg.f6441.6

                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                                                            4. Applied rewrites41.6%

                                                              \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                                                            5. Taylor expanded in K around 0

                                                              \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                                            6. Step-by-step derivation
                                                              1. Applied rewrites99.2%

                                                                \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]

                                                              if -27 < M < 3.35e16

                                                              1. Initial program 67.1%

                                                                \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                              2. Add Preprocessing
                                                              3. Taylor expanded in K around 0

                                                                \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)}} \]
                                                              4. Step-by-step derivation
                                                                1. *-commutativeN/A

                                                                  \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                                                                2. lower-*.f64N/A

                                                                  \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {\left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}^{2}\right)} \cdot \cos \left(\mathsf{neg}\left(M\right)\right)} \]
                                                              5. Applied rewrites91.6%

                                                                \[\leadsto \color{blue}{e^{\left|m - n\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \cdot \cos M} \]
                                                              6. Taylor expanded in n around inf

                                                                \[\leadsto e^{\frac{-1}{4} \cdot {n}^{2}} \cdot \cos M \]
                                                              7. Step-by-step derivation
                                                                1. Applied rewrites54.7%

                                                                  \[\leadsto e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M \]
                                                                2. Taylor expanded in M around 0

                                                                  \[\leadsto e^{\left(n \cdot n\right) \cdot \frac{-1}{4}} \cdot \left(1 + \color{blue}{\frac{-1}{2} \cdot {M}^{2}}\right) \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites54.7%

                                                                    \[\leadsto e^{\left(n \cdot n\right) \cdot -0.25} \cdot \mathsf{fma}\left(M \cdot M, \color{blue}{-0.5}, 1\right) \]
                                                                4. Recombined 2 regimes into one program.
                                                                5. Final simplification77.3%

                                                                  \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -27:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{elif}\;M \leq 3.35 \cdot 10^{+16}:\\ \;\;\;\;\mathsf{fma}\left(M \cdot M, -0.5, 1\right) \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
                                                                6. Add Preprocessing

                                                                Alternative 10: 71.2% accurate, 2.6× speedup?

                                                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-\ell}\\ t_1 := e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{if}\;M \leq -2.8 \cdot 10^{+14}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;M \leq -4.9 \cdot 10^{-206}:\\ \;\;\;\;t\_0 \cdot \mathsf{fma}\left(M \cdot M, -0.5, 1\right)\\ \mathbf{elif}\;M \leq 3.2 \cdot 10^{-15}:\\ \;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                                                                (FPCore (K m n M l)
                                                                 :precision binary64
                                                                 (let* ((t_0 (exp (- l))) (t_1 (* (exp (* (- M) M)) 1.0)))
                                                                   (if (<= M -2.8e+14)
                                                                     t_1
                                                                     (if (<= M -4.9e-206)
                                                                       (* t_0 (fma (* M M) -0.5 1.0))
                                                                       (if (<= M 3.2e-15) (* (* (* M M) -0.5) t_0) t_1)))))
                                                                double code(double K, double m, double n, double M, double l) {
                                                                	double t_0 = exp(-l);
                                                                	double t_1 = exp((-M * M)) * 1.0;
                                                                	double tmp;
                                                                	if (M <= -2.8e+14) {
                                                                		tmp = t_1;
                                                                	} else if (M <= -4.9e-206) {
                                                                		tmp = t_0 * fma((M * M), -0.5, 1.0);
                                                                	} else if (M <= 3.2e-15) {
                                                                		tmp = ((M * M) * -0.5) * t_0;
                                                                	} else {
                                                                		tmp = t_1;
                                                                	}
                                                                	return tmp;
                                                                }
                                                                
                                                                function code(K, m, n, M, l)
                                                                	t_0 = exp(Float64(-l))
                                                                	t_1 = Float64(exp(Float64(Float64(-M) * M)) * 1.0)
                                                                	tmp = 0.0
                                                                	if (M <= -2.8e+14)
                                                                		tmp = t_1;
                                                                	elseif (M <= -4.9e-206)
                                                                		tmp = Float64(t_0 * fma(Float64(M * M), -0.5, 1.0));
                                                                	elseif (M <= 3.2e-15)
                                                                		tmp = Float64(Float64(Float64(M * M) * -0.5) * t_0);
                                                                	else
                                                                		tmp = t_1;
                                                                	end
                                                                	return tmp
                                                                end
                                                                
                                                                code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, Block[{t$95$1 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -2.8e+14], t$95$1, If[LessEqual[M, -4.9e-206], N[(t$95$0 * N[(N[(M * M), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 3.2e-15], N[(N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision] * t$95$0), $MachinePrecision], t$95$1]]]]]
                                                                
                                                                \begin{array}{l}
                                                                
                                                                \\
                                                                \begin{array}{l}
                                                                t_0 := e^{-\ell}\\
                                                                t_1 := e^{\left(-M\right) \cdot M} \cdot 1\\
                                                                \mathbf{if}\;M \leq -2.8 \cdot 10^{+14}:\\
                                                                \;\;\;\;t\_1\\
                                                                
                                                                \mathbf{elif}\;M \leq -4.9 \cdot 10^{-206}:\\
                                                                \;\;\;\;t\_0 \cdot \mathsf{fma}\left(M \cdot M, -0.5, 1\right)\\
                                                                
                                                                \mathbf{elif}\;M \leq 3.2 \cdot 10^{-15}:\\
                                                                \;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot t\_0\\
                                                                
                                                                \mathbf{else}:\\
                                                                \;\;\;\;t\_1\\
                                                                
                                                                
                                                                \end{array}
                                                                \end{array}
                                                                
                                                                Derivation
                                                                1. Split input into 3 regimes
                                                                2. if M < -2.8e14 or 3.1999999999999999e-15 < M

                                                                  1. Initial program 76.5%

                                                                    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                  2. Add Preprocessing
                                                                  3. Taylor expanded in K around 0

                                                                    \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                  4. Step-by-step derivation
                                                                    1. +-commutativeN/A

                                                                      \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    2. associate-*r*N/A

                                                                      \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    3. lower-fma.f64N/A

                                                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    4. lower-*.f64N/A

                                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    5. *-commutativeN/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    6. lower-*.f64N/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    7. +-commutativeN/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    8. lower-+.f64N/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    9. sin-negN/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    10. lower-neg.f64N/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    11. lower-sin.f64N/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    12. cos-negN/A

                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    13. lower-cos.f6477.3

                                                                      \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                  5. Applied rewrites77.3%

                                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                  6. Taylor expanded in M around 0

                                                                    \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                  7. Step-by-step derivation
                                                                    1. Applied rewrites42.4%

                                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                    2. Taylor expanded in M around inf

                                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                                                                    3. Step-by-step derivation
                                                                      1. mul-1-negN/A

                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                                                                      2. unpow2N/A

                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                                                                      3. distribute-lft-neg-inN/A

                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                                      4. lower-*.f64N/A

                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                                      5. lower-neg.f6440.2

                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                                                                    4. Applied rewrites40.2%

                                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                                                                    5. Taylor expanded in K around 0

                                                                      \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                                                    6. Step-by-step derivation
                                                                      1. Applied rewrites97.8%

                                                                        \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]

                                                                      if -2.8e14 < M < -4.9e-206

                                                                      1. Initial program 79.4%

                                                                        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                      2. Add Preprocessing
                                                                      3. Taylor expanded in l around inf

                                                                        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-1 \cdot \ell}} \]
                                                                      4. Step-by-step derivation
                                                                        1. mul-1-negN/A

                                                                          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
                                                                        2. lower-neg.f6450.2

                                                                          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
                                                                      5. Applied rewrites50.2%

                                                                        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
                                                                      6. Taylor expanded in K around 0

                                                                        \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)} \cdot e^{-\ell} \]
                                                                      7. Step-by-step derivation
                                                                        1. cos-negN/A

                                                                          \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                        2. lower-cos.f6450.9

                                                                          \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                      8. Applied rewrites50.9%

                                                                        \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                      9. Taylor expanded in M around 0

                                                                        \[\leadsto \left(1 + \color{blue}{\frac{-1}{2} \cdot {M}^{2}}\right) \cdot e^{-\ell} \]
                                                                      10. Step-by-step derivation
                                                                        1. Applied rewrites50.9%

                                                                          \[\leadsto \mathsf{fma}\left(M \cdot M, \color{blue}{-0.5}, 1\right) \cdot e^{-\ell} \]

                                                                        if -4.9e-206 < M < 3.1999999999999999e-15

                                                                        1. Initial program 62.3%

                                                                          \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                        2. Add Preprocessing
                                                                        3. Taylor expanded in l around inf

                                                                          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-1 \cdot \ell}} \]
                                                                        4. Step-by-step derivation
                                                                          1. mul-1-negN/A

                                                                            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
                                                                          2. lower-neg.f6431.0

                                                                            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
                                                                        5. Applied rewrites31.0%

                                                                          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
                                                                        6. Taylor expanded in K around 0

                                                                          \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)} \cdot e^{-\ell} \]
                                                                        7. Step-by-step derivation
                                                                          1. cos-negN/A

                                                                            \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                          2. lower-cos.f6442.2

                                                                            \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                        8. Applied rewrites42.2%

                                                                          \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                        9. Taylor expanded in M around 0

                                                                          \[\leadsto \left(1 + \color{blue}{\frac{-1}{2} \cdot {M}^{2}}\right) \cdot e^{-\ell} \]
                                                                        10. Step-by-step derivation
                                                                          1. Applied rewrites42.2%

                                                                            \[\leadsto \mathsf{fma}\left(M \cdot M, \color{blue}{-0.5}, 1\right) \cdot e^{-\ell} \]
                                                                          2. Taylor expanded in M around inf

                                                                            \[\leadsto \left(\frac{-1}{2} \cdot {M}^{\color{blue}{2}}\right) \cdot e^{-\ell} \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites56.5%

                                                                              \[\leadsto \left(\left(M \cdot M\right) \cdot -0.5\right) \cdot e^{-\ell} \]
                                                                          4. Recombined 3 regimes into one program.
                                                                          5. Final simplification76.9%

                                                                            \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.8 \cdot 10^{+14}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{elif}\;M \leq -4.9 \cdot 10^{-206}:\\ \;\;\;\;e^{-\ell} \cdot \mathsf{fma}\left(M \cdot M, -0.5, 1\right)\\ \mathbf{elif}\;M \leq 3.2 \cdot 10^{-15}:\\ \;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
                                                                          6. Add Preprocessing

                                                                          Alternative 11: 70.4% accurate, 2.8× speedup?

                                                                          \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{if}\;M \leq -2.8 \cdot 10^{+14}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 3.2 \cdot 10^{-15}:\\ \;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                                                          (FPCore (K m n M l)
                                                                           :precision binary64
                                                                           (let* ((t_0 (* (exp (* (- M) M)) 1.0)))
                                                                             (if (<= M -2.8e+14)
                                                                               t_0
                                                                               (if (<= M 3.2e-15) (* (* (* M M) -0.5) (exp (- l))) t_0))))
                                                                          double code(double K, double m, double n, double M, double l) {
                                                                          	double t_0 = exp((-M * M)) * 1.0;
                                                                          	double tmp;
                                                                          	if (M <= -2.8e+14) {
                                                                          		tmp = t_0;
                                                                          	} else if (M <= 3.2e-15) {
                                                                          		tmp = ((M * M) * -0.5) * exp(-l);
                                                                          	} else {
                                                                          		tmp = t_0;
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          real(8) function code(k, m, n, m_1, l)
                                                                              real(8), intent (in) :: k
                                                                              real(8), intent (in) :: m
                                                                              real(8), intent (in) :: n
                                                                              real(8), intent (in) :: m_1
                                                                              real(8), intent (in) :: l
                                                                              real(8) :: t_0
                                                                              real(8) :: tmp
                                                                              t_0 = exp((-m_1 * m_1)) * 1.0d0
                                                                              if (m_1 <= (-2.8d+14)) then
                                                                                  tmp = t_0
                                                                              else if (m_1 <= 3.2d-15) then
                                                                                  tmp = ((m_1 * m_1) * (-0.5d0)) * exp(-l)
                                                                              else
                                                                                  tmp = t_0
                                                                              end if
                                                                              code = tmp
                                                                          end function
                                                                          
                                                                          public static double code(double K, double m, double n, double M, double l) {
                                                                          	double t_0 = Math.exp((-M * M)) * 1.0;
                                                                          	double tmp;
                                                                          	if (M <= -2.8e+14) {
                                                                          		tmp = t_0;
                                                                          	} else if (M <= 3.2e-15) {
                                                                          		tmp = ((M * M) * -0.5) * Math.exp(-l);
                                                                          	} else {
                                                                          		tmp = t_0;
                                                                          	}
                                                                          	return tmp;
                                                                          }
                                                                          
                                                                          def code(K, m, n, M, l):
                                                                          	t_0 = math.exp((-M * M)) * 1.0
                                                                          	tmp = 0
                                                                          	if M <= -2.8e+14:
                                                                          		tmp = t_0
                                                                          	elif M <= 3.2e-15:
                                                                          		tmp = ((M * M) * -0.5) * math.exp(-l)
                                                                          	else:
                                                                          		tmp = t_0
                                                                          	return tmp
                                                                          
                                                                          function code(K, m, n, M, l)
                                                                          	t_0 = Float64(exp(Float64(Float64(-M) * M)) * 1.0)
                                                                          	tmp = 0.0
                                                                          	if (M <= -2.8e+14)
                                                                          		tmp = t_0;
                                                                          	elseif (M <= 3.2e-15)
                                                                          		tmp = Float64(Float64(Float64(M * M) * -0.5) * exp(Float64(-l)));
                                                                          	else
                                                                          		tmp = t_0;
                                                                          	end
                                                                          	return tmp
                                                                          end
                                                                          
                                                                          function tmp_2 = code(K, m, n, M, l)
                                                                          	t_0 = exp((-M * M)) * 1.0;
                                                                          	tmp = 0.0;
                                                                          	if (M <= -2.8e+14)
                                                                          		tmp = t_0;
                                                                          	elseif (M <= 3.2e-15)
                                                                          		tmp = ((M * M) * -0.5) * exp(-l);
                                                                          	else
                                                                          		tmp = t_0;
                                                                          	end
                                                                          	tmp_2 = tmp;
                                                                          end
                                                                          
                                                                          code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[M, -2.8e+14], t$95$0, If[LessEqual[M, 3.2e-15], N[(N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], t$95$0]]]
                                                                          
                                                                          \begin{array}{l}
                                                                          
                                                                          \\
                                                                          \begin{array}{l}
                                                                          t_0 := e^{\left(-M\right) \cdot M} \cdot 1\\
                                                                          \mathbf{if}\;M \leq -2.8 \cdot 10^{+14}:\\
                                                                          \;\;\;\;t\_0\\
                                                                          
                                                                          \mathbf{elif}\;M \leq 3.2 \cdot 10^{-15}:\\
                                                                          \;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot e^{-\ell}\\
                                                                          
                                                                          \mathbf{else}:\\
                                                                          \;\;\;\;t\_0\\
                                                                          
                                                                          
                                                                          \end{array}
                                                                          \end{array}
                                                                          
                                                                          Derivation
                                                                          1. Split input into 2 regimes
                                                                          2. if M < -2.8e14 or 3.1999999999999999e-15 < M

                                                                            1. Initial program 76.5%

                                                                              \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                            2. Add Preprocessing
                                                                            3. Taylor expanded in K around 0

                                                                              \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                            4. Step-by-step derivation
                                                                              1. +-commutativeN/A

                                                                                \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              2. associate-*r*N/A

                                                                                \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              3. lower-fma.f64N/A

                                                                                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              4. lower-*.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              5. *-commutativeN/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              6. lower-*.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              7. +-commutativeN/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              8. lower-+.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              9. sin-negN/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              10. lower-neg.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              11. lower-sin.f64N/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              12. cos-negN/A

                                                                                \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              13. lower-cos.f6477.3

                                                                                \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                            5. Applied rewrites77.3%

                                                                              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                            6. Taylor expanded in M around 0

                                                                              \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                            7. Step-by-step derivation
                                                                              1. Applied rewrites42.4%

                                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                              2. Taylor expanded in M around inf

                                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                                                                              3. Step-by-step derivation
                                                                                1. mul-1-negN/A

                                                                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                                                                                2. unpow2N/A

                                                                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                                                                                3. distribute-lft-neg-inN/A

                                                                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                                                4. lower-*.f64N/A

                                                                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                                                5. lower-neg.f6440.2

                                                                                  \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                                                                              4. Applied rewrites40.2%

                                                                                \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                                                                              5. Taylor expanded in K around 0

                                                                                \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                                                              6. Step-by-step derivation
                                                                                1. Applied rewrites97.8%

                                                                                  \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]

                                                                                if -2.8e14 < M < 3.1999999999999999e-15

                                                                                1. Initial program 68.2%

                                                                                  \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                2. Add Preprocessing
                                                                                3. Taylor expanded in l around inf

                                                                                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-1 \cdot \ell}} \]
                                                                                4. Step-by-step derivation
                                                                                  1. mul-1-negN/A

                                                                                    \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
                                                                                  2. lower-neg.f6437.6

                                                                                    \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
                                                                                5. Applied rewrites37.6%

                                                                                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
                                                                                6. Taylor expanded in K around 0

                                                                                  \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)} \cdot e^{-\ell} \]
                                                                                7. Step-by-step derivation
                                                                                  1. cos-negN/A

                                                                                    \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                                  2. lower-cos.f6445.2

                                                                                    \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                                8. Applied rewrites45.2%

                                                                                  \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
                                                                                9. Taylor expanded in M around 0

                                                                                  \[\leadsto \left(1 + \color{blue}{\frac{-1}{2} \cdot {M}^{2}}\right) \cdot e^{-\ell} \]
                                                                                10. Step-by-step derivation
                                                                                  1. Applied rewrites45.2%

                                                                                    \[\leadsto \mathsf{fma}\left(M \cdot M, \color{blue}{-0.5}, 1\right) \cdot e^{-\ell} \]
                                                                                  2. Taylor expanded in M around inf

                                                                                    \[\leadsto \left(\frac{-1}{2} \cdot {M}^{\color{blue}{2}}\right) \cdot e^{-\ell} \]
                                                                                  3. Step-by-step derivation
                                                                                    1. Applied rewrites47.7%

                                                                                      \[\leadsto \left(\left(M \cdot M\right) \cdot -0.5\right) \cdot e^{-\ell} \]
                                                                                  4. Recombined 2 regimes into one program.
                                                                                  5. Final simplification73.5%

                                                                                    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.8 \cdot 10^{+14}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \mathbf{elif}\;M \leq 3.2 \cdot 10^{-15}:\\ \;\;\;\;\left(\left(M \cdot M\right) \cdot -0.5\right) \cdot e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot 1\\ \end{array} \]
                                                                                  6. Add Preprocessing

                                                                                  Alternative 12: 54.9% accurate, 3.2× speedup?

                                                                                  \[\begin{array}{l} \\ e^{\left(-M\right) \cdot M} \cdot 1 \end{array} \]
                                                                                  (FPCore (K m n M l) :precision binary64 (* (exp (* (- M) M)) 1.0))
                                                                                  double code(double K, double m, double n, double M, double l) {
                                                                                  	return exp((-M * M)) * 1.0;
                                                                                  }
                                                                                  
                                                                                  real(8) function code(k, m, n, m_1, l)
                                                                                      real(8), intent (in) :: k
                                                                                      real(8), intent (in) :: m
                                                                                      real(8), intent (in) :: n
                                                                                      real(8), intent (in) :: m_1
                                                                                      real(8), intent (in) :: l
                                                                                      code = exp((-m_1 * m_1)) * 1.0d0
                                                                                  end function
                                                                                  
                                                                                  public static double code(double K, double m, double n, double M, double l) {
                                                                                  	return Math.exp((-M * M)) * 1.0;
                                                                                  }
                                                                                  
                                                                                  def code(K, m, n, M, l):
                                                                                  	return math.exp((-M * M)) * 1.0
                                                                                  
                                                                                  function code(K, m, n, M, l)
                                                                                  	return Float64(exp(Float64(Float64(-M) * M)) * 1.0)
                                                                                  end
                                                                                  
                                                                                  function tmp = code(K, m, n, M, l)
                                                                                  	tmp = exp((-M * M)) * 1.0;
                                                                                  end
                                                                                  
                                                                                  code[K_, m_, n_, M_, l_] := N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]
                                                                                  
                                                                                  \begin{array}{l}
                                                                                  
                                                                                  \\
                                                                                  e^{\left(-M\right) \cdot M} \cdot 1
                                                                                  \end{array}
                                                                                  
                                                                                  Derivation
                                                                                  1. Initial program 72.5%

                                                                                    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                  2. Add Preprocessing
                                                                                  3. Taylor expanded in K around 0

                                                                                    \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + \frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                  4. Step-by-step derivation
                                                                                    1. +-commutativeN/A

                                                                                      \[\leadsto \color{blue}{\left(\frac{-1}{2} \cdot \left(K \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\right) + \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    2. associate-*r*N/A

                                                                                      \[\leadsto \left(\color{blue}{\left(\frac{-1}{2} \cdot K\right) \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)} + \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    3. lower-fma.f64N/A

                                                                                      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{2} \cdot K, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    4. lower-*.f64N/A

                                                                                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{-1}{2} \cdot K}, \sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    5. *-commutativeN/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    6. lower-*.f64N/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(m + n\right) \cdot \sin \left(\mathsf{neg}\left(M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    7. +-commutativeN/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    8. lower-+.f64N/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \color{blue}{\left(n + m\right)} \cdot \sin \left(\mathsf{neg}\left(M\right)\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    9. sin-negN/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(\mathsf{neg}\left(\sin M\right)\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    10. lower-neg.f64N/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \color{blue}{\left(-\sin M\right)}, \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    11. lower-sin.f64N/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\color{blue}{\sin M}\right), \cos \left(\mathsf{neg}\left(M\right)\right)\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    12. cos-negN/A

                                                                                      \[\leadsto \mathsf{fma}\left(\frac{-1}{2} \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    13. lower-cos.f6481.6

                                                                                      \[\leadsto \mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \color{blue}{\cos M}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                  5. Applied rewrites81.6%

                                                                                    \[\leadsto \color{blue}{\mathsf{fma}\left(-0.5 \cdot K, \left(n + m\right) \cdot \left(-\sin M\right), \cos M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                  6. Taylor expanded in M around 0

                                                                                    \[\leadsto \left(1 + \color{blue}{\frac{1}{2} \cdot \left(K \cdot \left(M \cdot \left(m + n\right)\right)\right)}\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                  7. Step-by-step derivation
                                                                                    1. Applied rewrites62.9%

                                                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \color{blue}{0.5}, 1\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                                                                                    2. Taylor expanded in M around inf

                                                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                                                                                    3. Step-by-step derivation
                                                                                      1. mul-1-negN/A

                                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                                                                                      2. unpow2N/A

                                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                                                                                      3. distribute-lft-neg-inN/A

                                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                                                      4. lower-*.f64N/A

                                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, \frac{1}{2}, 1\right) \cdot e^{\color{blue}{\left(\mathsf{neg}\left(M\right)\right) \cdot M}} \]
                                                                                      5. lower-neg.f6428.4

                                                                                        \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right)} \cdot M} \]
                                                                                    4. Applied rewrites28.4%

                                                                                      \[\leadsto \mathsf{fma}\left(\left(M \cdot \left(n + m\right)\right) \cdot K, 0.5, 1\right) \cdot e^{\color{blue}{\left(-M\right) \cdot M}} \]
                                                                                    5. Taylor expanded in K around 0

                                                                                      \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                                                                    6. Step-by-step derivation
                                                                                      1. Applied rewrites58.4%

                                                                                        \[\leadsto 1 \cdot e^{\left(-M\right) \cdot M} \]
                                                                                      2. Final simplification58.4%

                                                                                        \[\leadsto e^{\left(-M\right) \cdot M} \cdot 1 \]
                                                                                      3. Add Preprocessing

                                                                                      Reproduce

                                                                                      ?
                                                                                      herbie shell --seed 2024331 
                                                                                      (FPCore (K m n M l)
                                                                                        :name "Maksimov and Kolovsky, Equation (32)"
                                                                                        :precision binary64
                                                                                        (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))