Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 75.9% → 96.6%
Time: 9.0s
Alternatives: 10
Speedup: 1.1×

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 10 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: 75.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.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \cos M \cdot e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (* (cos M) (exp (- (fabs (- n m)) (+ (pow (fma 0.5 (+ n m) (- M)) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
	return cos(M) * exp((fabs((n - m)) - (pow(fma(0.5, (n + m), -M), 2.0) + l)));
}
function code(K, m, n, M, l)
	return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((fma(0.5, Float64(n + m), Float64(-M)) ^ 2.0) + l))))
end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * 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]), $MachinePrecision]
\begin{array}{l}

\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\mathsf{fma}\left(0.5, n + m, -M\right)\right)}^{2} + \ell\right)}
\end{array}
Derivation
  1. Initial program 75.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}{\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 rewrites97.1%

    \[\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 simplification97.1%

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

Alternative 2: 62.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\ \;\;\;\;e^{-\ell} \cdot \cos \left(\frac{K}{\frac{2}{n + m}} - M\right)\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (<= n 1e-281)
   (* (exp (* -0.25 (* m m))) (cos M))
   (if (<= n 4.5e-100)
     (* (exp (- l)) (cos (- (/ K (/ 2.0 (+ n m))) M)))
     (if (<= n 54.0)
       (* (exp (* (- M) M)) (cos M))
       (* (exp (* (* n n) -0.25)) 1.0)))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (n <= 1e-281) {
		tmp = exp((-0.25 * (m * m))) * cos(M);
	} else if (n <= 4.5e-100) {
		tmp = exp(-l) * cos(((K / (2.0 / (n + m))) - M));
	} else if (n <= 54.0) {
		tmp = exp((-M * M)) * cos(M);
	} else {
		tmp = exp(((n * n) * -0.25)) * 1.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) :: tmp
    if (n <= 1d-281) then
        tmp = exp(((-0.25d0) * (m * m))) * cos(m_1)
    else if (n <= 4.5d-100) then
        tmp = exp(-l) * cos(((k / (2.0d0 / (n + m))) - m_1))
    else if (n <= 54.0d0) then
        tmp = exp((-m_1 * m_1)) * cos(m_1)
    else
        tmp = exp(((n * n) * (-0.25d0))) * 1.0d0
    end if
    code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (n <= 1e-281) {
		tmp = Math.exp((-0.25 * (m * m))) * Math.cos(M);
	} else if (n <= 4.5e-100) {
		tmp = Math.exp(-l) * Math.cos(((K / (2.0 / (n + m))) - M));
	} else if (n <= 54.0) {
		tmp = Math.exp((-M * M)) * Math.cos(M);
	} else {
		tmp = Math.exp(((n * n) * -0.25)) * 1.0;
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if n <= 1e-281:
		tmp = math.exp((-0.25 * (m * m))) * math.cos(M)
	elif n <= 4.5e-100:
		tmp = math.exp(-l) * math.cos(((K / (2.0 / (n + m))) - M))
	elif n <= 54.0:
		tmp = math.exp((-M * M)) * math.cos(M)
	else:
		tmp = math.exp(((n * n) * -0.25)) * 1.0
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if (n <= 1e-281)
		tmp = Float64(exp(Float64(-0.25 * Float64(m * m))) * cos(M));
	elseif (n <= 4.5e-100)
		tmp = Float64(exp(Float64(-l)) * cos(Float64(Float64(K / Float64(2.0 / Float64(n + m))) - M)));
	elseif (n <= 54.0)
		tmp = Float64(exp(Float64(Float64(-M) * M)) * cos(M));
	else
		tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0);
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	tmp = 0.0;
	if (n <= 1e-281)
		tmp = exp((-0.25 * (m * m))) * cos(M);
	elseif (n <= 4.5e-100)
		tmp = exp(-l) * cos(((K / (2.0 / (n + m))) - M));
	elseif (n <= 54.0)
		tmp = exp((-M * M)) * cos(M);
	else
		tmp = exp(((n * n) * -0.25)) * 1.0;
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1e-281], N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.5e-100], N[(N[Exp[(-l)], $MachinePrecision] * N[Cos[N[(N[(K / N[(2.0 / N[(n + m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq 10^{-281}:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\

\mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\
\;\;\;\;e^{-\ell} \cdot \cos \left(\frac{K}{\frac{2}{n + m}} - M\right)\\

\mathbf{elif}\;n \leq 54:\\
\;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\

\mathbf{else}:\\
\;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\


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

    1. Initial program 73.9%

      \[\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 m around inf

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

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

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

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
      4. lower-*.f6442.6

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

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

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

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
      2. lower-cos.f6460.5

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
    8. Applied rewrites60.5%

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

    if 1e-281 < n < 4.5000000000000001e-100

    1. Initial program 87.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.f6446.6

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

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

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

        \[\leadsto \cos \left(\frac{\color{blue}{K \cdot \left(m + n\right)}}{2} - M\right) \cdot e^{-\ell} \]
      3. associate-/l*N/A

        \[\leadsto \cos \left(\color{blue}{K \cdot \frac{m + n}{2}} - M\right) \cdot e^{-\ell} \]
      4. clear-numN/A

        \[\leadsto \cos \left(K \cdot \color{blue}{\frac{1}{\frac{2}{m + n}}} - M\right) \cdot e^{-\ell} \]
      5. un-div-invN/A

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

        \[\leadsto \cos \left(\color{blue}{\frac{K}{\frac{2}{m + n}}} - M\right) \cdot e^{-\ell} \]
      7. lower-/.f6447.5

        \[\leadsto \cos \left(\frac{K}{\color{blue}{\frac{2}{m + n}}} - M\right) \cdot e^{-\ell} \]
      8. lift-+.f64N/A

        \[\leadsto \cos \left(\frac{K}{\frac{2}{\color{blue}{m + n}}} - M\right) \cdot e^{-\ell} \]
      9. +-commutativeN/A

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

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

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

    if 4.5000000000000001e-100 < n < 54

    1. Initial program 79.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 rewrites87.1%

      \[\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 rewrites49.2%

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

      if 54 < n

      1. Initial program 70.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 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.f6426.0

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
      5. Applied rewrites26.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.f6434.9

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

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

        \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
      10. Step-by-step derivation
        1. lower-*.f64N/A

          \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
        2. unpow2N/A

          \[\leadsto \cos M \cdot e^{\frac{-1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
        3. lower-*.f6498.4

          \[\leadsto \cos M \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
      11. Applied rewrites98.4%

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

        \[\leadsto 1 \cdot e^{\frac{-1}{4} \cdot \left(n \cdot n\right)} \]
      13. Step-by-step derivation
        1. Applied rewrites98.4%

          \[\leadsto 1 \cdot e^{-0.25 \cdot \left(n \cdot n\right)} \]
      14. Recombined 4 regimes into one program.
      15. Final simplification66.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\ \;\;\;\;e^{-\ell} \cdot \cos \left(\frac{K}{\frac{2}{n + m}} - M\right)\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \]
      16. Add Preprocessing

      Alternative 3: 62.8% accurate, 1.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(0.5 \cdot n, K, \left(m \cdot K\right) \cdot 0.5\right) - M\right) \cdot e^{-\ell}\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \end{array} \]
      (FPCore (K m n M l)
       :precision binary64
       (if (<= n 1e-281)
         (* (exp (* -0.25 (* m m))) (cos M))
         (if (<= n 4.5e-100)
           (* (cos (- (fma (* 0.5 n) K (* (* m K) 0.5)) M)) (exp (- l)))
           (if (<= n 54.0)
             (* (exp (* (- M) M)) (cos M))
             (* (exp (* (* n n) -0.25)) 1.0)))))
      double code(double K, double m, double n, double M, double l) {
      	double tmp;
      	if (n <= 1e-281) {
      		tmp = exp((-0.25 * (m * m))) * cos(M);
      	} else if (n <= 4.5e-100) {
      		tmp = cos((fma((0.5 * n), K, ((m * K) * 0.5)) - M)) * exp(-l);
      	} else if (n <= 54.0) {
      		tmp = exp((-M * M)) * cos(M);
      	} else {
      		tmp = exp(((n * n) * -0.25)) * 1.0;
      	}
      	return tmp;
      }
      
      function code(K, m, n, M, l)
      	tmp = 0.0
      	if (n <= 1e-281)
      		tmp = Float64(exp(Float64(-0.25 * Float64(m * m))) * cos(M));
      	elseif (n <= 4.5e-100)
      		tmp = Float64(cos(Float64(fma(Float64(0.5 * n), K, Float64(Float64(m * K) * 0.5)) - M)) * exp(Float64(-l)));
      	elseif (n <= 54.0)
      		tmp = Float64(exp(Float64(Float64(-M) * M)) * cos(M));
      	else
      		tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0);
      	end
      	return tmp
      end
      
      code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1e-281], N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.5e-100], N[(N[Cos[N[(N[(N[(0.5 * n), $MachinePrecision] * K + N[(N[(m * K), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;n \leq 10^{-281}:\\
      \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\
      
      \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\
      \;\;\;\;\cos \left(\mathsf{fma}\left(0.5 \cdot n, K, \left(m \cdot K\right) \cdot 0.5\right) - M\right) \cdot e^{-\ell}\\
      
      \mathbf{elif}\;n \leq 54:\\
      \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\
      
      \mathbf{else}:\\
      \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if n < 1e-281

        1. Initial program 73.9%

          \[\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 m around inf

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

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

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

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
          4. lower-*.f6442.6

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

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

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

            \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
          2. lower-cos.f6460.5

            \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
        8. Applied rewrites60.5%

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

        if 1e-281 < n < 4.5000000000000001e-100

        1. Initial program 87.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.f6446.6

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

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

            \[\leadsto \cos \left(\color{blue}{\frac{K \cdot \left(m + n\right)}{2}} - M\right) \cdot e^{-\ell} \]
          2. div-invN/A

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

            \[\leadsto \cos \left(\color{blue}{\left(K \cdot \left(m + n\right)\right)} \cdot \frac{1}{2} - M\right) \cdot e^{-\ell} \]
          4. metadata-evalN/A

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

            \[\leadsto \cos \left(\color{blue}{K \cdot \left(\left(m + n\right) \cdot \frac{1}{2}\right)} - M\right) \cdot e^{-\ell} \]
          6. *-commutativeN/A

            \[\leadsto \cos \left(K \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(m + n\right)\right)} - M\right) \cdot e^{-\ell} \]
          7. lift-+.f64N/A

            \[\leadsto \cos \left(K \cdot \left(\frac{1}{2} \cdot \color{blue}{\left(m + n\right)}\right) - M\right) \cdot e^{-\ell} \]
          8. distribute-lft-inN/A

            \[\leadsto \cos \left(K \cdot \color{blue}{\left(\frac{1}{2} \cdot m + \frac{1}{2} \cdot n\right)} - M\right) \cdot e^{-\ell} \]
          9. +-commutativeN/A

            \[\leadsto \cos \left(K \cdot \color{blue}{\left(\frac{1}{2} \cdot n + \frac{1}{2} \cdot m\right)} - M\right) \cdot e^{-\ell} \]
          10. distribute-rgt-inN/A

            \[\leadsto \cos \left(\color{blue}{\left(\left(\frac{1}{2} \cdot n\right) \cdot K + \left(\frac{1}{2} \cdot m\right) \cdot K\right)} - M\right) \cdot e^{-\ell} \]
          11. *-commutativeN/A

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

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

            \[\leadsto \cos \left(\left(\left(n \cdot \frac{1}{2}\right) \cdot K + \frac{1}{2} \cdot \color{blue}{\left(m \cdot K\right)}\right) - M\right) \cdot e^{-\ell} \]
          14. *-commutativeN/A

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

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

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

            \[\leadsto \cos \left(\mathsf{fma}\left(\color{blue}{\frac{1}{2} \cdot n}, K, \left(m \cdot K\right) \cdot \frac{1}{2}\right) - M\right) \cdot e^{-\ell} \]
          18. lower-*.f6446.6

            \[\leadsto \cos \left(\mathsf{fma}\left(0.5 \cdot n, K, \color{blue}{\left(m \cdot K\right) \cdot 0.5}\right) - M\right) \cdot e^{-\ell} \]
        7. Applied rewrites46.6%

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

        if 4.5000000000000001e-100 < n < 54

        1. Initial program 79.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 rewrites87.1%

          \[\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 rewrites49.2%

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

          if 54 < n

          1. Initial program 70.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 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.f6426.0

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
          5. Applied rewrites26.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.f6434.9

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

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

            \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
          10. Step-by-step derivation
            1. lower-*.f64N/A

              \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
            2. unpow2N/A

              \[\leadsto \cos M \cdot e^{\frac{-1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
            3. lower-*.f6498.4

              \[\leadsto \cos M \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
          11. Applied rewrites98.4%

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

            \[\leadsto 1 \cdot e^{\frac{-1}{4} \cdot \left(n \cdot n\right)} \]
          13. Step-by-step derivation
            1. Applied rewrites98.4%

              \[\leadsto 1 \cdot e^{-0.25 \cdot \left(n \cdot n\right)} \]
          14. Recombined 4 regimes into one program.
          15. Final simplification66.0%

            \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\ \;\;\;\;\cos \left(\mathsf{fma}\left(0.5 \cdot n, K, \left(m \cdot K\right) \cdot 0.5\right) - M\right) \cdot e^{-\ell}\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \]
          16. Add Preprocessing

          Alternative 4: 62.8% accurate, 1.5× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\ \;\;\;\;\cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{-\ell}\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \end{array} \]
          (FPCore (K m n M l)
           :precision binary64
           (if (<= n 1e-281)
             (* (exp (* -0.25 (* m m))) (cos M))
             (if (<= n 4.5e-100)
               (* (cos (- (/ (* (+ n m) K) 2.0) M)) (exp (- l)))
               (if (<= n 54.0)
                 (* (exp (* (- M) M)) (cos M))
                 (* (exp (* (* n n) -0.25)) 1.0)))))
          double code(double K, double m, double n, double M, double l) {
          	double tmp;
          	if (n <= 1e-281) {
          		tmp = exp((-0.25 * (m * m))) * cos(M);
          	} else if (n <= 4.5e-100) {
          		tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(-l);
          	} else if (n <= 54.0) {
          		tmp = exp((-M * M)) * cos(M);
          	} else {
          		tmp = exp(((n * n) * -0.25)) * 1.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) :: tmp
              if (n <= 1d-281) then
                  tmp = exp(((-0.25d0) * (m * m))) * cos(m_1)
              else if (n <= 4.5d-100) then
                  tmp = cos(((((n + m) * k) / 2.0d0) - m_1)) * exp(-l)
              else if (n <= 54.0d0) then
                  tmp = exp((-m_1 * m_1)) * cos(m_1)
              else
                  tmp = exp(((n * n) * (-0.25d0))) * 1.0d0
              end if
              code = tmp
          end function
          
          public static double code(double K, double m, double n, double M, double l) {
          	double tmp;
          	if (n <= 1e-281) {
          		tmp = Math.exp((-0.25 * (m * m))) * Math.cos(M);
          	} else if (n <= 4.5e-100) {
          		tmp = Math.cos(((((n + m) * K) / 2.0) - M)) * Math.exp(-l);
          	} else if (n <= 54.0) {
          		tmp = Math.exp((-M * M)) * Math.cos(M);
          	} else {
          		tmp = Math.exp(((n * n) * -0.25)) * 1.0;
          	}
          	return tmp;
          }
          
          def code(K, m, n, M, l):
          	tmp = 0
          	if n <= 1e-281:
          		tmp = math.exp((-0.25 * (m * m))) * math.cos(M)
          	elif n <= 4.5e-100:
          		tmp = math.cos(((((n + m) * K) / 2.0) - M)) * math.exp(-l)
          	elif n <= 54.0:
          		tmp = math.exp((-M * M)) * math.cos(M)
          	else:
          		tmp = math.exp(((n * n) * -0.25)) * 1.0
          	return tmp
          
          function code(K, m, n, M, l)
          	tmp = 0.0
          	if (n <= 1e-281)
          		tmp = Float64(exp(Float64(-0.25 * Float64(m * m))) * cos(M));
          	elseif (n <= 4.5e-100)
          		tmp = Float64(cos(Float64(Float64(Float64(Float64(n + m) * K) / 2.0) - M)) * exp(Float64(-l)));
          	elseif (n <= 54.0)
          		tmp = Float64(exp(Float64(Float64(-M) * M)) * cos(M));
          	else
          		tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0);
          	end
          	return tmp
          end
          
          function tmp_2 = code(K, m, n, M, l)
          	tmp = 0.0;
          	if (n <= 1e-281)
          		tmp = exp((-0.25 * (m * m))) * cos(M);
          	elseif (n <= 4.5e-100)
          		tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(-l);
          	elseif (n <= 54.0)
          		tmp = exp((-M * M)) * cos(M);
          	else
          		tmp = exp(((n * n) * -0.25)) * 1.0;
          	end
          	tmp_2 = tmp;
          end
          
          code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1e-281], N[(N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.5e-100], N[(N[Cos[N[(N[(N[(N[(n + m), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 54.0], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;n \leq 10^{-281}:\\
          \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\
          
          \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\
          \;\;\;\;\cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{-\ell}\\
          
          \mathbf{elif}\;n \leq 54:\\
          \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\
          
          \mathbf{else}:\\
          \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if n < 1e-281

            1. Initial program 73.9%

              \[\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 m around inf

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

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

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

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
              4. lower-*.f6442.6

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

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

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

                \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
              2. lower-cos.f6460.5

                \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
            8. Applied rewrites60.5%

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

            if 1e-281 < n < 4.5000000000000001e-100

            1. Initial program 87.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.f6446.6

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

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

            if 4.5000000000000001e-100 < n < 54

            1. Initial program 79.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 rewrites87.1%

              \[\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 rewrites49.2%

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

              if 54 < n

              1. Initial program 70.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 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.f6426.0

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
              5. Applied rewrites26.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.f6434.9

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

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

                \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
              10. Step-by-step derivation
                1. lower-*.f64N/A

                  \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                2. unpow2N/A

                  \[\leadsto \cos M \cdot e^{\frac{-1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
                3. lower-*.f6498.4

                  \[\leadsto \cos M \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
              11. Applied rewrites98.4%

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

                \[\leadsto 1 \cdot e^{\frac{-1}{4} \cdot \left(n \cdot n\right)} \]
              13. Step-by-step derivation
                1. Applied rewrites98.4%

                  \[\leadsto 1 \cdot e^{-0.25 \cdot \left(n \cdot n\right)} \]
              14. Recombined 4 regimes into one program.
              15. Final simplification66.0%

                \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)} \cdot \cos M\\ \mathbf{elif}\;n \leq 4.5 \cdot 10^{-100}:\\ \;\;\;\;\cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{-\ell}\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \]
              16. Add Preprocessing

              Alternative 5: 64.6% accurate, 1.6× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.88:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;m \leq -4.5 \cdot 10^{-266}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M\\ \end{array} \end{array} \]
              (FPCore (K m n M l)
               :precision binary64
               (if (<= m -0.88)
                 (* 1.0 (exp (* -0.25 (* m m))))
                 (if (<= m -4.5e-266)
                   (* (exp (* (- M) M)) (cos M))
                   (* (exp (* (* n n) -0.25)) (cos M)))))
              double code(double K, double m, double n, double M, double l) {
              	double tmp;
              	if (m <= -0.88) {
              		tmp = 1.0 * exp((-0.25 * (m * m)));
              	} else if (m <= -4.5e-266) {
              		tmp = exp((-M * M)) * cos(M);
              	} else {
              		tmp = exp(((n * n) * -0.25)) * cos(M);
              	}
              	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) :: tmp
                  if (m <= (-0.88d0)) then
                      tmp = 1.0d0 * exp(((-0.25d0) * (m * m)))
                  else if (m <= (-4.5d-266)) then
                      tmp = exp((-m_1 * m_1)) * cos(m_1)
                  else
                      tmp = exp(((n * n) * (-0.25d0))) * cos(m_1)
                  end if
                  code = tmp
              end function
              
              public static double code(double K, double m, double n, double M, double l) {
              	double tmp;
              	if (m <= -0.88) {
              		tmp = 1.0 * Math.exp((-0.25 * (m * m)));
              	} else if (m <= -4.5e-266) {
              		tmp = Math.exp((-M * M)) * Math.cos(M);
              	} else {
              		tmp = Math.exp(((n * n) * -0.25)) * Math.cos(M);
              	}
              	return tmp;
              }
              
              def code(K, m, n, M, l):
              	tmp = 0
              	if m <= -0.88:
              		tmp = 1.0 * math.exp((-0.25 * (m * m)))
              	elif m <= -4.5e-266:
              		tmp = math.exp((-M * M)) * math.cos(M)
              	else:
              		tmp = math.exp(((n * n) * -0.25)) * math.cos(M)
              	return tmp
              
              function code(K, m, n, M, l)
              	tmp = 0.0
              	if (m <= -0.88)
              		tmp = Float64(1.0 * exp(Float64(-0.25 * Float64(m * m))));
              	elseif (m <= -4.5e-266)
              		tmp = Float64(exp(Float64(Float64(-M) * M)) * cos(M));
              	else
              		tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * cos(M));
              	end
              	return tmp
              end
              
              function tmp_2 = code(K, m, n, M, l)
              	tmp = 0.0;
              	if (m <= -0.88)
              		tmp = 1.0 * exp((-0.25 * (m * m)));
              	elseif (m <= -4.5e-266)
              		tmp = exp((-M * M)) * cos(M);
              	else
              		tmp = exp(((n * n) * -0.25)) * cos(M);
              	end
              	tmp_2 = tmp;
              end
              
              code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.88], N[(1.0 * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -4.5e-266], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;m \leq -0.88:\\
              \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
              
              \mathbf{elif}\;m \leq -4.5 \cdot 10^{-266}:\\
              \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\
              
              \mathbf{else}:\\
              \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if m < -0.880000000000000004

                1. Initial program 68.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 m around inf

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                  2. lower-cos.f6495.8

                    \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                8. Applied rewrites95.8%

                  \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                9. Taylor expanded in M around 0

                  \[\leadsto 1 \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                10. Step-by-step derivation
                  1. Applied rewrites95.8%

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

                  if -0.880000000000000004 < m < -4.5000000000000003e-266

                  1. Initial program 72.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.0%

                    \[\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 rewrites55.5%

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

                    if -4.5000000000000003e-266 < m

                    1. Initial program 80.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 rewrites97.4%

                      \[\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 rewrites50.0%

                        \[\leadsto e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M \]
                    8. Recombined 3 regimes into one program.
                    9. Final simplification63.4%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -0.88:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;m \leq -4.5 \cdot 10^{-266}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot \cos M\\ \end{array} \]
                    10. Add Preprocessing

                    Alternative 6: 64.6% accurate, 1.6× speedup?

                    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.88:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;m \leq -4.5 \cdot 10^{-266}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \end{array} \]
                    (FPCore (K m n M l)
                     :precision binary64
                     (if (<= m -0.88)
                       (* 1.0 (exp (* -0.25 (* m m))))
                       (if (<= m -4.5e-266)
                         (* (exp (* (- M) M)) (cos M))
                         (* (exp (* (* n n) -0.25)) 1.0))))
                    double code(double K, double m, double n, double M, double l) {
                    	double tmp;
                    	if (m <= -0.88) {
                    		tmp = 1.0 * exp((-0.25 * (m * m)));
                    	} else if (m <= -4.5e-266) {
                    		tmp = exp((-M * M)) * cos(M);
                    	} else {
                    		tmp = exp(((n * n) * -0.25)) * 1.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) :: tmp
                        if (m <= (-0.88d0)) then
                            tmp = 1.0d0 * exp(((-0.25d0) * (m * m)))
                        else if (m <= (-4.5d-266)) then
                            tmp = exp((-m_1 * m_1)) * cos(m_1)
                        else
                            tmp = exp(((n * n) * (-0.25d0))) * 1.0d0
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double K, double m, double n, double M, double l) {
                    	double tmp;
                    	if (m <= -0.88) {
                    		tmp = 1.0 * Math.exp((-0.25 * (m * m)));
                    	} else if (m <= -4.5e-266) {
                    		tmp = Math.exp((-M * M)) * Math.cos(M);
                    	} else {
                    		tmp = Math.exp(((n * n) * -0.25)) * 1.0;
                    	}
                    	return tmp;
                    }
                    
                    def code(K, m, n, M, l):
                    	tmp = 0
                    	if m <= -0.88:
                    		tmp = 1.0 * math.exp((-0.25 * (m * m)))
                    	elif m <= -4.5e-266:
                    		tmp = math.exp((-M * M)) * math.cos(M)
                    	else:
                    		tmp = math.exp(((n * n) * -0.25)) * 1.0
                    	return tmp
                    
                    function code(K, m, n, M, l)
                    	tmp = 0.0
                    	if (m <= -0.88)
                    		tmp = Float64(1.0 * exp(Float64(-0.25 * Float64(m * m))));
                    	elseif (m <= -4.5e-266)
                    		tmp = Float64(exp(Float64(Float64(-M) * M)) * cos(M));
                    	else
                    		tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0);
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(K, m, n, M, l)
                    	tmp = 0.0;
                    	if (m <= -0.88)
                    		tmp = 1.0 * exp((-0.25 * (m * m)));
                    	elseif (m <= -4.5e-266)
                    		tmp = exp((-M * M)) * cos(M);
                    	else
                    		tmp = exp(((n * n) * -0.25)) * 1.0;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.88], N[(1.0 * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -4.5e-266], N[(N[Exp[N[((-M) * M), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]]
                    
                    \begin{array}{l}
                    
                    \\
                    \begin{array}{l}
                    \mathbf{if}\;m \leq -0.88:\\
                    \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
                    
                    \mathbf{elif}\;m \leq -4.5 \cdot 10^{-266}:\\
                    \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
                    
                    
                    \end{array}
                    \end{array}
                    
                    Derivation
                    1. Split input into 3 regimes
                    2. if m < -0.880000000000000004

                      1. Initial program 68.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 m around inf

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

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

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

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

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

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

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

                          \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                        2. lower-cos.f6495.8

                          \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                      8. Applied rewrites95.8%

                        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                      9. Taylor expanded in M around 0

                        \[\leadsto 1 \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                      10. Step-by-step derivation
                        1. Applied rewrites95.8%

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

                        if -0.880000000000000004 < m < -4.5000000000000003e-266

                        1. Initial program 72.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.0%

                          \[\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 rewrites55.5%

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

                          if -4.5000000000000003e-266 < m

                          1. Initial program 80.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 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.f6433.1

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

                            \[\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.f6436.3

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

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

                            \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                          10. Step-by-step derivation
                            1. lower-*.f64N/A

                              \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                            2. unpow2N/A

                              \[\leadsto \cos M \cdot e^{\frac{-1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
                            3. lower-*.f6450.0

                              \[\leadsto \cos M \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
                          11. Applied rewrites50.0%

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

                            \[\leadsto 1 \cdot e^{\frac{-1}{4} \cdot \left(n \cdot n\right)} \]
                          13. Step-by-step derivation
                            1. Applied rewrites50.0%

                              \[\leadsto 1 \cdot e^{-0.25 \cdot \left(n \cdot n\right)} \]
                          14. Recombined 3 regimes into one program.
                          15. Final simplification63.4%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -0.88:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;m \leq -4.5 \cdot 10^{-266}:\\ \;\;\;\;e^{\left(-M\right) \cdot M} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \]
                          16. Add Preprocessing

                          Alternative 7: 61.9% accurate, 1.6× speedup?

                          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;n \leq 2.5 \cdot 10^{-5}:\\ \;\;\;\;e^{-\ell} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \end{array} \]
                          (FPCore (K m n M l)
                           :precision binary64
                           (if (<= n 1e-281)
                             (* 1.0 (exp (* -0.25 (* m m))))
                             (if (<= n 2.5e-5) (* (exp (- l)) (cos M)) (* (exp (* (* n n) -0.25)) 1.0))))
                          double code(double K, double m, double n, double M, double l) {
                          	double tmp;
                          	if (n <= 1e-281) {
                          		tmp = 1.0 * exp((-0.25 * (m * m)));
                          	} else if (n <= 2.5e-5) {
                          		tmp = exp(-l) * cos(M);
                          	} else {
                          		tmp = exp(((n * n) * -0.25)) * 1.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) :: tmp
                              if (n <= 1d-281) then
                                  tmp = 1.0d0 * exp(((-0.25d0) * (m * m)))
                              else if (n <= 2.5d-5) then
                                  tmp = exp(-l) * cos(m_1)
                              else
                                  tmp = exp(((n * n) * (-0.25d0))) * 1.0d0
                              end if
                              code = tmp
                          end function
                          
                          public static double code(double K, double m, double n, double M, double l) {
                          	double tmp;
                          	if (n <= 1e-281) {
                          		tmp = 1.0 * Math.exp((-0.25 * (m * m)));
                          	} else if (n <= 2.5e-5) {
                          		tmp = Math.exp(-l) * Math.cos(M);
                          	} else {
                          		tmp = Math.exp(((n * n) * -0.25)) * 1.0;
                          	}
                          	return tmp;
                          }
                          
                          def code(K, m, n, M, l):
                          	tmp = 0
                          	if n <= 1e-281:
                          		tmp = 1.0 * math.exp((-0.25 * (m * m)))
                          	elif n <= 2.5e-5:
                          		tmp = math.exp(-l) * math.cos(M)
                          	else:
                          		tmp = math.exp(((n * n) * -0.25)) * 1.0
                          	return tmp
                          
                          function code(K, m, n, M, l)
                          	tmp = 0.0
                          	if (n <= 1e-281)
                          		tmp = Float64(1.0 * exp(Float64(-0.25 * Float64(m * m))));
                          	elseif (n <= 2.5e-5)
                          		tmp = Float64(exp(Float64(-l)) * cos(M));
                          	else
                          		tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0);
                          	end
                          	return tmp
                          end
                          
                          function tmp_2 = code(K, m, n, M, l)
                          	tmp = 0.0;
                          	if (n <= 1e-281)
                          		tmp = 1.0 * exp((-0.25 * (m * m)));
                          	elseif (n <= 2.5e-5)
                          		tmp = exp(-l) * cos(M);
                          	else
                          		tmp = exp(((n * n) * -0.25)) * 1.0;
                          	end
                          	tmp_2 = tmp;
                          end
                          
                          code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1e-281], N[(1.0 * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.5e-5], N[(N[Exp[(-l)], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]]
                          
                          \begin{array}{l}
                          
                          \\
                          \begin{array}{l}
                          \mathbf{if}\;n \leq 10^{-281}:\\
                          \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
                          
                          \mathbf{elif}\;n \leq 2.5 \cdot 10^{-5}:\\
                          \;\;\;\;e^{-\ell} \cdot \cos M\\
                          
                          \mathbf{else}:\\
                          \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
                          
                          
                          \end{array}
                          \end{array}
                          
                          Derivation
                          1. Split input into 3 regimes
                          2. if n < 1e-281

                            1. Initial program 73.9%

                              \[\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 m around inf

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

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

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

                                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
                              4. lower-*.f6442.6

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

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

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

                                \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                              2. lower-cos.f6460.5

                                \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                            8. Applied rewrites60.5%

                              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                            9. Taylor expanded in M around 0

                              \[\leadsto 1 \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                            10. Step-by-step derivation
                              1. Applied rewrites60.5%

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

                              if 1e-281 < n < 2.50000000000000012e-5

                              1. Initial program 84.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 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.f6445.5

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

                                \[\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.f6447.2

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

                                \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]

                              if 2.50000000000000012e-5 < n

                              1. Initial program 70.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 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.f6424.8

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

                                \[\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.f6432.9

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

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

                                \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                              10. Step-by-step derivation
                                1. lower-*.f64N/A

                                  \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                                2. unpow2N/A

                                  \[\leadsto \cos M \cdot e^{\frac{-1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
                                3. lower-*.f6492.4

                                  \[\leadsto \cos M \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
                              11. Applied rewrites92.4%

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

                                \[\leadsto 1 \cdot e^{\frac{-1}{4} \cdot \left(n \cdot n\right)} \]
                              13. Step-by-step derivation
                                1. Applied rewrites92.4%

                                  \[\leadsto 1 \cdot e^{-0.25 \cdot \left(n \cdot n\right)} \]
                              14. Recombined 3 regimes into one program.
                              15. Final simplification65.2%

                                \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 10^{-281}:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;n \leq 2.5 \cdot 10^{-5}:\\ \;\;\;\;e^{-\ell} \cdot \cos M\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \]
                              16. Add Preprocessing

                              Alternative 8: 67.3% accurate, 2.8× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \mathbf{if}\;n \leq -2.7 \cdot 10^{-56}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq 2.5 \cdot 10^{-5}:\\ \;\;\;\;1 \cdot e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                              (FPCore (K m n M l)
                               :precision binary64
                               (let* ((t_0 (* (exp (* (* n n) -0.25)) 1.0)))
                                 (if (<= n -2.7e-56) t_0 (if (<= n 2.5e-5) (* 1.0 (exp (- l))) t_0))))
                              double code(double K, double m, double n, double M, double l) {
                              	double t_0 = exp(((n * n) * -0.25)) * 1.0;
                              	double tmp;
                              	if (n <= -2.7e-56) {
                              		tmp = t_0;
                              	} else if (n <= 2.5e-5) {
                              		tmp = 1.0 * 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(((n * n) * (-0.25d0))) * 1.0d0
                                  if (n <= (-2.7d-56)) then
                                      tmp = t_0
                                  else if (n <= 2.5d-5) then
                                      tmp = 1.0d0 * 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(((n * n) * -0.25)) * 1.0;
                              	double tmp;
                              	if (n <= -2.7e-56) {
                              		tmp = t_0;
                              	} else if (n <= 2.5e-5) {
                              		tmp = 1.0 * Math.exp(-l);
                              	} else {
                              		tmp = t_0;
                              	}
                              	return tmp;
                              }
                              
                              def code(K, m, n, M, l):
                              	t_0 = math.exp(((n * n) * -0.25)) * 1.0
                              	tmp = 0
                              	if n <= -2.7e-56:
                              		tmp = t_0
                              	elif n <= 2.5e-5:
                              		tmp = 1.0 * math.exp(-l)
                              	else:
                              		tmp = t_0
                              	return tmp
                              
                              function code(K, m, n, M, l)
                              	t_0 = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0)
                              	tmp = 0.0
                              	if (n <= -2.7e-56)
                              		tmp = t_0;
                              	elseif (n <= 2.5e-5)
                              		tmp = Float64(1.0 * exp(Float64(-l)));
                              	else
                              		tmp = t_0;
                              	end
                              	return tmp
                              end
                              
                              function tmp_2 = code(K, m, n, M, l)
                              	t_0 = exp(((n * n) * -0.25)) * 1.0;
                              	tmp = 0.0;
                              	if (n <= -2.7e-56)
                              		tmp = t_0;
                              	elseif (n <= 2.5e-5)
                              		tmp = 1.0 * 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[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]}, If[LessEqual[n, -2.7e-56], t$95$0, If[LessEqual[n, 2.5e-5], N[(1.0 * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], t$95$0]]]
                              
                              \begin{array}{l}
                              
                              \\
                              \begin{array}{l}
                              t_0 := e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
                              \mathbf{if}\;n \leq -2.7 \cdot 10^{-56}:\\
                              \;\;\;\;t\_0\\
                              
                              \mathbf{elif}\;n \leq 2.5 \cdot 10^{-5}:\\
                              \;\;\;\;1 \cdot e^{-\ell}\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;t\_0\\
                              
                              
                              \end{array}
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if n < -2.69999999999999995e-56 or 2.50000000000000012e-5 < n

                                1. Initial program 67.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 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.f6421.9

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

                                  \[\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.f6427.4

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

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

                                  \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                                10. Step-by-step derivation
                                  1. lower-*.f64N/A

                                    \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                                  2. unpow2N/A

                                    \[\leadsto \cos M \cdot e^{\frac{-1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
                                  3. lower-*.f6486.9

                                    \[\leadsto \cos M \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
                                11. Applied rewrites86.9%

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

                                  \[\leadsto 1 \cdot e^{\frac{-1}{4} \cdot \left(n \cdot n\right)} \]
                                13. Step-by-step derivation
                                  1. Applied rewrites86.9%

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

                                  if -2.69999999999999995e-56 < n < 2.50000000000000012e-5

                                  1. Initial program 85.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 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.f6438.3

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

                                    \[\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.f6441.1

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

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

                                    \[\leadsto 1 \cdot e^{-\ell} \]
                                  10. Step-by-step derivation
                                    1. Applied rewrites39.4%

                                      \[\leadsto 1 \cdot e^{-\ell} \]
                                  11. Recombined 2 regimes into one program.
                                  12. Final simplification65.6%

                                    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.7 \cdot 10^{-56}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \mathbf{elif}\;n \leq 2.5 \cdot 10^{-5}:\\ \;\;\;\;1 \cdot e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \]
                                  13. Add Preprocessing

                                  Alternative 9: 64.3% accurate, 2.9× speedup?

                                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.095:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \end{array} \]
                                  (FPCore (K m n M l)
                                   :precision binary64
                                   (if (<= m -0.095)
                                     (* 1.0 (exp (* -0.25 (* m m))))
                                     (* (exp (* (* n n) -0.25)) 1.0)))
                                  double code(double K, double m, double n, double M, double l) {
                                  	double tmp;
                                  	if (m <= -0.095) {
                                  		tmp = 1.0 * exp((-0.25 * (m * m)));
                                  	} else {
                                  		tmp = exp(((n * n) * -0.25)) * 1.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) :: tmp
                                      if (m <= (-0.095d0)) then
                                          tmp = 1.0d0 * exp(((-0.25d0) * (m * m)))
                                      else
                                          tmp = exp(((n * n) * (-0.25d0))) * 1.0d0
                                      end if
                                      code = tmp
                                  end function
                                  
                                  public static double code(double K, double m, double n, double M, double l) {
                                  	double tmp;
                                  	if (m <= -0.095) {
                                  		tmp = 1.0 * Math.exp((-0.25 * (m * m)));
                                  	} else {
                                  		tmp = Math.exp(((n * n) * -0.25)) * 1.0;
                                  	}
                                  	return tmp;
                                  }
                                  
                                  def code(K, m, n, M, l):
                                  	tmp = 0
                                  	if m <= -0.095:
                                  		tmp = 1.0 * math.exp((-0.25 * (m * m)))
                                  	else:
                                  		tmp = math.exp(((n * n) * -0.25)) * 1.0
                                  	return tmp
                                  
                                  function code(K, m, n, M, l)
                                  	tmp = 0.0
                                  	if (m <= -0.095)
                                  		tmp = Float64(1.0 * exp(Float64(-0.25 * Float64(m * m))));
                                  	else
                                  		tmp = Float64(exp(Float64(Float64(n * n) * -0.25)) * 1.0);
                                  	end
                                  	return tmp
                                  end
                                  
                                  function tmp_2 = code(K, m, n, M, l)
                                  	tmp = 0.0;
                                  	if (m <= -0.095)
                                  		tmp = 1.0 * exp((-0.25 * (m * m)));
                                  	else
                                  		tmp = exp(((n * n) * -0.25)) * 1.0;
                                  	end
                                  	tmp_2 = tmp;
                                  end
                                  
                                  code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.095], N[(1.0 * N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(n * n), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision]]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \begin{array}{l}
                                  \mathbf{if}\;m \leq -0.095:\\
                                  \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
                                  
                                  \mathbf{else}:\\
                                  \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\
                                  
                                  
                                  \end{array}
                                  \end{array}
                                  
                                  Derivation
                                  1. Split input into 2 regimes
                                  2. if m < -0.095000000000000001

                                    1. Initial program 69.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 m around inf

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

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

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

                                        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
                                      4. lower-*.f6464.9

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

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

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

                                        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                                      2. lower-cos.f6494.5

                                        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                                    8. Applied rewrites94.5%

                                      \[\leadsto \color{blue}{\cos M} \cdot e^{\left(m \cdot m\right) \cdot -0.25} \]
                                    9. Taylor expanded in M around 0

                                      \[\leadsto 1 \cdot e^{\left(m \cdot m\right) \cdot \frac{-1}{4}} \]
                                    10. Step-by-step derivation
                                      1. Applied rewrites94.5%

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

                                      if -0.095000000000000001 < m

                                      1. Initial program 78.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.f6434.0

                                          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
                                      5. Applied rewrites34.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.f6437.6

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

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

                                        \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                                      10. Step-by-step derivation
                                        1. lower-*.f64N/A

                                          \[\leadsto \cos M \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
                                        2. unpow2N/A

                                          \[\leadsto \cos M \cdot e^{\frac{-1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
                                        3. lower-*.f6450.9

                                          \[\leadsto \cos M \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
                                      11. Applied rewrites50.9%

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

                                        \[\leadsto 1 \cdot e^{\frac{-1}{4} \cdot \left(n \cdot n\right)} \]
                                      13. Step-by-step derivation
                                        1. Applied rewrites50.9%

                                          \[\leadsto 1 \cdot e^{-0.25 \cdot \left(n \cdot n\right)} \]
                                      14. Recombined 2 regimes into one program.
                                      15. Final simplification63.0%

                                        \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -0.095:\\ \;\;\;\;1 \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(n \cdot n\right) \cdot -0.25} \cdot 1\\ \end{array} \]
                                      16. Add Preprocessing

                                      Alternative 10: 35.6% accurate, 3.3× speedup?

                                      \[\begin{array}{l} \\ 1 \cdot e^{-\ell} \end{array} \]
                                      (FPCore (K m n M l) :precision binary64 (* 1.0 (exp (- l))))
                                      double code(double K, double m, double n, double M, double l) {
                                      	return 1.0 * exp(-l);
                                      }
                                      
                                      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 = 1.0d0 * exp(-l)
                                      end function
                                      
                                      public static double code(double K, double m, double n, double M, double l) {
                                      	return 1.0 * Math.exp(-l);
                                      }
                                      
                                      def code(K, m, n, M, l):
                                      	return 1.0 * math.exp(-l)
                                      
                                      function code(K, m, n, M, l)
                                      	return Float64(1.0 * exp(Float64(-l)))
                                      end
                                      
                                      function tmp = code(K, m, n, M, l)
                                      	tmp = 1.0 * exp(-l);
                                      end
                                      
                                      code[K_, m_, n_, M_, l_] := N[(1.0 * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
                                      
                                      \begin{array}{l}
                                      
                                      \\
                                      1 \cdot e^{-\ell}
                                      \end{array}
                                      
                                      Derivation
                                      1. Initial program 75.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 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.f6429.3

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

                                        \[\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.f6433.6

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

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

                                        \[\leadsto 1 \cdot e^{-\ell} \]
                                      10. Step-by-step derivation
                                        1. Applied rewrites32.8%

                                          \[\leadsto 1 \cdot e^{-\ell} \]
                                        2. Add Preprocessing

                                        Reproduce

                                        ?
                                        herbie shell --seed 2024288 
                                        (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)))))))