Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.3% → 96.9%
Time: 13.7s
Alternatives: 9
Speedup: 2.9×

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 9 alternatives:

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

Initial Program: 76.3% 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.9% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(m + n\right) - M\\ \cos M \cdot e^{\ell \cdot \left(-1 - \frac{t\_0 \cdot t\_0 - \left|m - n\right|}{\ell}\right)} \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (- (* 0.5 (+ m n)) M)))
   (* (cos M) (exp (* l (- -1.0 (/ (- (* t_0 t_0) (fabs (- m n))) l)))))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = (0.5 * (m + n)) - M;
	return cos(M) * exp((l * (-1.0 - (((t_0 * t_0) - fabs((m - n))) / 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
    real(8) :: t_0
    t_0 = (0.5d0 * (m + n)) - m_1
    code = cos(m_1) * exp((l * ((-1.0d0) - (((t_0 * t_0) - abs((m - n))) / l))))
end function
public static double code(double K, double m, double n, double M, double l) {
	double t_0 = (0.5 * (m + n)) - M;
	return Math.cos(M) * Math.exp((l * (-1.0 - (((t_0 * t_0) - Math.abs((m - n))) / l))));
}
def code(K, m, n, M, l):
	t_0 = (0.5 * (m + n)) - M
	return math.cos(M) * math.exp((l * (-1.0 - (((t_0 * t_0) - math.fabs((m - n))) / l))))
function code(K, m, n, M, l)
	t_0 = Float64(Float64(0.5 * Float64(m + n)) - M)
	return Float64(cos(M) * exp(Float64(l * Float64(-1.0 - Float64(Float64(Float64(t_0 * t_0) - abs(Float64(m - n))) / l)))))
end
function tmp = code(K, m, n, M, l)
	t_0 = (0.5 * (m + n)) - M;
	tmp = cos(M) * exp((l * (-1.0 - (((t_0 * t_0) - abs((m - n))) / l))));
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(l * N[(-1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(m + n\right) - M\\
\cos M \cdot e^{\ell \cdot \left(-1 - \frac{t\_0 \cdot t\_0 - \left|m - n\right|}{\ell}\right)}
\end{array}
\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(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
  4. Step-by-step derivation
    1. cos-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.5% accurate, 2.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(m + n\right) - M\\ e^{\ell \cdot \left(-1 - \frac{t\_0 \cdot t\_0 - \left|m - n\right|}{\ell}\right)} \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (- (* 0.5 (+ m n)) M)))
   (exp (* l (- -1.0 (/ (- (* t_0 t_0) (fabs (- m n))) l))))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = (0.5 * (m + n)) - M;
	return exp((l * (-1.0 - (((t_0 * t_0) - fabs((m - n))) / 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
    real(8) :: t_0
    t_0 = (0.5d0 * (m + n)) - m_1
    code = exp((l * ((-1.0d0) - (((t_0 * t_0) - abs((m - n))) / l))))
end function
public static double code(double K, double m, double n, double M, double l) {
	double t_0 = (0.5 * (m + n)) - M;
	return Math.exp((l * (-1.0 - (((t_0 * t_0) - Math.abs((m - n))) / l))));
}
def code(K, m, n, M, l):
	t_0 = (0.5 * (m + n)) - M
	return math.exp((l * (-1.0 - (((t_0 * t_0) - math.fabs((m - n))) / l))))
function code(K, m, n, M, l)
	t_0 = Float64(Float64(0.5 * Float64(m + n)) - M)
	return exp(Float64(l * Float64(-1.0 - Float64(Float64(Float64(t_0 * t_0) - abs(Float64(m - n))) / l))))
end
function tmp = code(K, m, n, M, l)
	t_0 = (0.5 * (m + n)) - M;
	tmp = exp((l * (-1.0 - (((t_0 * t_0) - abs((m - n))) / l))));
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]}, N[Exp[N[(l * N[(-1.0 - N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(m + n\right) - M\\
e^{\ell \cdot \left(-1 - \frac{t\_0 \cdot t\_0 - \left|m - n\right|}{\ell}\right)}
\end{array}
\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(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
  4. Step-by-step derivation
    1. cos-negN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 3: 94.4% accurate, 2.6× speedup?

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

      1. Initial program 80.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto 1 \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
        3. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto 1 \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
          2. unpow2N/A

            \[\leadsto 1 \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
          3. distribute-rgt-neg-inN/A

            \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
          4. lower-*.f64N/A

            \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
          5. lower-neg.f64100.0

            \[\leadsto 1 \cdot e^{M \cdot \color{blue}{\left(-M\right)}} \]
        4. Applied rewrites100.0%

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

        if -2.79999999999999981e101 < M < 5.00000000000000022e41

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

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

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

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

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

          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
        7. Step-by-step derivation
          1. lower-exp.f64N/A

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

            \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
          3. lower-fabs.f64N/A

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

            \[\leadsto e^{\left|\color{blue}{m - n}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
          5. +-commutativeN/A

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)}} \]
      11. Recombined 2 regimes into one program.
      12. Final simplification95.4%

        \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.8 \cdot 10^{+101}:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \mathbf{elif}\;M \leq 5 \cdot 10^{+41}:\\ \;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \end{array} \]
      13. Add Preprocessing

      Alternative 4: 66.0% accurate, 2.9× speedup?

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

        1. Initial program 69.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto 1 \cdot e^{\color{blue}{\frac{-1}{4} \cdot {m}^{2}}} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto 1 \cdot e^{\color{blue}{{m}^{2} \cdot \frac{-1}{4}}} \]
            2. lower-*.f64N/A

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

              \[\leadsto 1 \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
            4. lower-*.f6497.5

              \[\leadsto 1 \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
          4. Applied rewrites97.5%

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

          if -0.340000000000000024 < m < -1e-255

          1. Initial program 84.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto 1 \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
            3. Step-by-step derivation
              1. mul-1-negN/A

                \[\leadsto 1 \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
              2. unpow2N/A

                \[\leadsto 1 \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
              3. distribute-rgt-neg-inN/A

                \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
              4. lower-*.f64N/A

                \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
              5. lower-neg.f6463.5

                \[\leadsto 1 \cdot e^{M \cdot \color{blue}{\left(-M\right)}} \]
            4. Applied rewrites63.5%

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

            if -1e-255 < m

            1. Initial program 76.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto 1 \cdot e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
              3. Step-by-step derivation
                1. *-commutativeN/A

                  \[\leadsto 1 \cdot e^{\color{blue}{{n}^{2} \cdot \frac{-1}{4}}} \]
                2. lower-*.f64N/A

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

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

                  \[\leadsto 1 \cdot e^{\color{blue}{\left(n \cdot n\right)} \cdot -0.25} \]
              4. Applied rewrites55.0%

                \[\leadsto 1 \cdot e^{\color{blue}{\left(n \cdot n\right) \cdot -0.25}} \]
            11. Recombined 3 regimes into one program.
            12. Final simplification69.3%

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

            Alternative 5: 76.7% accurate, 2.9× speedup?

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

              1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto 1 \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                3. Step-by-step derivation
                  1. mul-1-negN/A

                    \[\leadsto 1 \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                  2. unpow2N/A

                    \[\leadsto 1 \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                  3. distribute-rgt-neg-inN/A

                    \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
                  4. lower-*.f64N/A

                    \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
                  5. lower-neg.f6498.5

                    \[\leadsto 1 \cdot e^{M \cdot \color{blue}{\left(-M\right)}} \]
                4. Applied rewrites98.5%

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

                if -1.6e21 < M < 27

                1. Initial program 67.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto 1 \cdot e^{\color{blue}{\frac{-1}{4} \cdot {m}^{2}}} \]
                  3. Step-by-step derivation
                    1. *-commutativeN/A

                      \[\leadsto 1 \cdot e^{\color{blue}{{m}^{2} \cdot \frac{-1}{4}}} \]
                    2. lower-*.f64N/A

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

                      \[\leadsto 1 \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
                    4. lower-*.f6453.5

                      \[\leadsto 1 \cdot e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
                  4. Applied rewrites53.5%

                    \[\leadsto 1 \cdot e^{\color{blue}{\left(m \cdot m\right) \cdot -0.25}} \]
                11. Recombined 2 regimes into one program.
                12. Final simplification76.5%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -1.6 \cdot 10^{+21}:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \mathbf{elif}\;M \leq 27:\\ \;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \end{array} \]
                13. Add Preprocessing

                Alternative 6: 68.3% accurate, 3.0× speedup?

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

                  1. Initial program 83.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto 1 \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
                    3. Step-by-step derivation
                      1. mul-1-negN/A

                        \[\leadsto 1 \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
                      2. unpow2N/A

                        \[\leadsto 1 \cdot e^{\mathsf{neg}\left(\color{blue}{M \cdot M}\right)} \]
                      3. distribute-rgt-neg-inN/A

                        \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
                      4. lower-*.f64N/A

                        \[\leadsto 1 \cdot e^{\color{blue}{M \cdot \left(\mathsf{neg}\left(M\right)\right)}} \]
                      5. lower-neg.f6493.8

                        \[\leadsto 1 \cdot e^{M \cdot \color{blue}{\left(-M\right)}} \]
                    4. Applied rewrites93.8%

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

                    if -2.1e17 < M < 4.5e-63

                    1. Initial program 66.8%

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

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

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

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

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

                      \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot \ell}} \]
                    7. Step-by-step derivation
                      1. neg-mul-1N/A

                        \[\leadsto \cos M \cdot e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
                      2. lower-neg.f6434.8

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

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

                      \[\leadsto \color{blue}{e^{\mathsf{neg}\left(\ell\right)}} \]
                    10. Step-by-step derivation
                      1. neg-mul-1N/A

                        \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
                      2. lower-exp.f64N/A

                        \[\leadsto \color{blue}{e^{-1 \cdot \ell}} \]
                      3. neg-mul-1N/A

                        \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
                      4. lower-neg.f6434.8

                        \[\leadsto e^{\color{blue}{-\ell}} \]
                    11. Applied rewrites34.8%

                      \[\leadsto \color{blue}{e^{-\ell}} \]
                  11. Recombined 2 regimes into one program.
                  12. Final simplification67.3%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.1 \cdot 10^{+17}:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \mathbf{elif}\;M \leq 4.5 \cdot 10^{-63}:\\ \;\;\;\;e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \end{array} \]
                  13. Add Preprocessing

                  Alternative 7: 35.3% accurate, 3.5× speedup?

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

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

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

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

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

                    \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot \ell}} \]
                  7. Step-by-step derivation
                    1. neg-mul-1N/A

                      \[\leadsto \cos M \cdot e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
                    2. lower-neg.f6429.6

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

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

                    \[\leadsto \color{blue}{e^{\mathsf{neg}\left(\ell\right)}} \]
                  10. Step-by-step derivation
                    1. neg-mul-1N/A

                      \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
                    2. lower-exp.f64N/A

                      \[\leadsto \color{blue}{e^{-1 \cdot \ell}} \]
                    3. neg-mul-1N/A

                      \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
                    4. lower-neg.f6429.6

                      \[\leadsto e^{\color{blue}{-\ell}} \]
                  11. Applied rewrites29.6%

                    \[\leadsto \color{blue}{e^{-\ell}} \]
                  12. Add Preprocessing

                  Alternative 8: 7.0% accurate, 3.6× speedup?

                  \[\begin{array}{l} \\ \cos M \end{array} \]
                  (FPCore (K m n M l) :precision binary64 (cos M))
                  double code(double K, double m, double n, double M, double l) {
                  	return cos(M);
                  }
                  
                  real(8) function code(k, m, n, m_1, l)
                      real(8), intent (in) :: k
                      real(8), intent (in) :: m
                      real(8), intent (in) :: n
                      real(8), intent (in) :: m_1
                      real(8), intent (in) :: l
                      code = cos(m_1)
                  end function
                  
                  public static double code(double K, double m, double n, double M, double l) {
                  	return Math.cos(M);
                  }
                  
                  def code(K, m, n, M, l):
                  	return math.cos(M)
                  
                  function code(K, m, n, M, l)
                  	return cos(M)
                  end
                  
                  function tmp = code(K, m, n, M, l)
                  	tmp = cos(M);
                  end
                  
                  code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  \cos M
                  \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 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-*.f6440.5

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

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

                    \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot \left(K \cdot n\right) - M\right)} \]
                  7. Step-by-step derivation
                    1. lower-cos.f64N/A

                      \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot \left(K \cdot n\right) - M\right)} \]
                    2. sub-negN/A

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

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

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

                      \[\leadsto \cos \left(\mathsf{fma}\left(\frac{1}{2}, \color{blue}{n \cdot K}, \mathsf{neg}\left(M\right)\right)\right) \]
                    6. lower-neg.f645.0

                      \[\leadsto \cos \left(\mathsf{fma}\left(0.5, n \cdot K, \color{blue}{-M}\right)\right) \]
                  8. Applied rewrites5.0%

                    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(0.5, n \cdot K, -M\right)\right)} \]
                  9. Taylor expanded in n around 0

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

                      \[\leadsto \color{blue}{\cos M} \]
                    2. lower-cos.f645.4

                      \[\leadsto \color{blue}{\cos M} \]
                  11. Applied rewrites5.4%

                    \[\leadsto \color{blue}{\cos M} \]
                  12. Add Preprocessing

                  Alternative 9: 6.9% accurate, 359.0× speedup?

                  \[\begin{array}{l} \\ 1 \end{array} \]
                  (FPCore (K m n M l) :precision binary64 1.0)
                  double code(double K, double m, double n, double M, double l) {
                  	return 1.0;
                  }
                  
                  real(8) function code(k, m, n, m_1, l)
                      real(8), intent (in) :: k
                      real(8), intent (in) :: m
                      real(8), intent (in) :: n
                      real(8), intent (in) :: m_1
                      real(8), intent (in) :: l
                      code = 1.0d0
                  end function
                  
                  public static double code(double K, double m, double n, double M, double l) {
                  	return 1.0;
                  }
                  
                  def code(K, m, n, M, l):
                  	return 1.0
                  
                  function code(K, m, n, M, l)
                  	return 1.0
                  end
                  
                  function tmp = code(K, m, n, M, l)
                  	tmp = 1.0;
                  end
                  
                  code[K_, m_, n_, M_, l_] := 1.0
                  
                  \begin{array}{l}
                  
                  \\
                  1
                  \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 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-*.f6440.5

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

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

                    \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot \left(K \cdot n\right) - M\right)} \]
                  7. Step-by-step derivation
                    1. lower-cos.f64N/A

                      \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot \left(K \cdot n\right) - M\right)} \]
                    2. sub-negN/A

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

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

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

                      \[\leadsto \cos \left(\mathsf{fma}\left(\frac{1}{2}, \color{blue}{n \cdot K}, \mathsf{neg}\left(M\right)\right)\right) \]
                    6. lower-neg.f645.0

                      \[\leadsto \cos \left(\mathsf{fma}\left(0.5, n \cdot K, \color{blue}{-M}\right)\right) \]
                  8. Applied rewrites5.0%

                    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left(0.5, n \cdot K, -M\right)\right)} \]
                  9. Taylor expanded in n around 0

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

                      \[\leadsto \color{blue}{\cos M} \]
                    2. lower-cos.f645.4

                      \[\leadsto \color{blue}{\cos M} \]
                  11. Applied rewrites5.4%

                    \[\leadsto \color{blue}{\cos M} \]
                  12. Taylor expanded in M around 0

                    \[\leadsto \color{blue}{1} \]
                  13. Step-by-step derivation
                    1. Applied rewrites5.4%

                      \[\leadsto \color{blue}{1} \]
                    2. Add Preprocessing

                    Reproduce

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