Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.3% → 96.7%
Time: 13.0s
Alternatives: 11
Speedup: 2.6×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

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

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

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

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

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

    \[\leadsto \color{blue}{\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.f6497.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. Simplified97.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. Final simplification97.4%

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

Alternative 2: 95.4% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{M \cdot \left(-M\right)}\\ \mathbf{if}\;M \leq -6200:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 28:\\ \;\;\;\;e^{\mathsf{fma}\left(-0.25, \left(m + n\right) \cdot \left(m + n\right), \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 -6200.0)
     t_0
     (if (<= M 28.0)
       (exp (fma -0.25 (* (+ m n) (+ m n)) (- (fabs (- 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 <= -6200.0) {
		tmp = t_0;
	} else if (M <= 28.0) {
		tmp = exp(fma(-0.25, ((m + n) * (m + n)), (fabs((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 <= -6200.0)
		tmp = t_0;
	elseif (M <= 28.0)
		tmp = exp(fma(-0.25, Float64(Float64(m + n) * Float64(m + n)), Float64(abs(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, -6200.0], t$95$0, If[LessEqual[M, 28.0], N[Exp[N[(-0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[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 -6200:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;M \leq 28:\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, \left(m + n\right) \cdot \left(m + n\right), \left|m - n\right| - \ell\right)}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < -6200 or 28 < M

    1. Initial program 80.5%

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

      \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)} \cdot e^{\left(\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. Simplified100.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 inf

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

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

        \[\leadsto \cos M \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
    8. Simplified83.7%

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

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

        \[\leadsto \color{blue}{1} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\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. lower-neg.f64N/A

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

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

          \[\leadsto 1 \cdot e^{-\color{blue}{M \cdot M}} \]
      4. Simplified99.3%

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

      if -6200 < M < 28

      1. Initial program 72.5%

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

        \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
      8. Simplified31.8%

        \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
      9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
        12. distribute-lft-neg-inN/A

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

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

          \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
      11. Simplified94.5%

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

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

    Alternative 3: 68.6% accurate, 2.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.00092:\\ \;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\ \mathbf{elif}\;m \leq -7.2 \cdot 10^{-300}:\\ \;\;\;\;e^{\left(\left|m - n\right| - \ell\right) - M \cdot M}\\ \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.00092)
       (exp (* m (* m -0.25)))
       (if (<= m -7.2e-300)
         (exp (- (- (fabs (- m n)) l) (* M M)))
         (exp (* -0.25 (* n n))))))
    double code(double K, double m, double n, double M, double l) {
    	double tmp;
    	if (m <= -0.00092) {
    		tmp = exp((m * (m * -0.25)));
    	} else if (m <= -7.2e-300) {
    		tmp = exp(((fabs((m - n)) - l) - (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.00092d0)) then
            tmp = exp((m * (m * (-0.25d0))))
        else if (m <= (-7.2d-300)) then
            tmp = exp(((abs((m - n)) - l) - (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.00092) {
    		tmp = Math.exp((m * (m * -0.25)));
    	} else if (m <= -7.2e-300) {
    		tmp = Math.exp(((Math.abs((m - n)) - l) - (M * M)));
    	} else {
    		tmp = Math.exp((-0.25 * (n * n)));
    	}
    	return tmp;
    }
    
    def code(K, m, n, M, l):
    	tmp = 0
    	if m <= -0.00092:
    		tmp = math.exp((m * (m * -0.25)))
    	elif m <= -7.2e-300:
    		tmp = math.exp(((math.fabs((m - n)) - l) - (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.00092)
    		tmp = exp(Float64(m * Float64(m * -0.25)));
    	elseif (m <= -7.2e-300)
    		tmp = exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(M * 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.00092)
    		tmp = exp((m * (m * -0.25)));
    	elseif (m <= -7.2e-300)
    		tmp = exp(((abs((m - n)) - l) - (M * M)));
    	else
    		tmp = exp((-0.25 * (n * n)));
    	end
    	tmp_2 = tmp;
    end
    
    code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.00092], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -7.2e-300], N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;m \leq -0.00092:\\
    \;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
    
    \mathbf{elif}\;m \leq -7.2 \cdot 10^{-300}:\\
    \;\;\;\;e^{\left(\left|m - n\right| - \ell\right) - M \cdot M}\\
    
    \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 < -9.2000000000000003e-4

      1. Initial program 62.7%

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

        \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

          \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
      8. Simplified16.9%

        \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
      9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
        12. distribute-lft-neg-inN/A

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

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

          \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
      11. Simplified98.3%

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

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

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

          \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
        3. associate-*r*N/A

          \[\leadsto e^{\color{blue}{m \cdot \left(m \cdot \frac{-1}{4}\right)}} \]
        4. *-commutativeN/A

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

          \[\leadsto e^{\color{blue}{m \cdot \left(\frac{-1}{4} \cdot m\right)}} \]
        6. *-commutativeN/A

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

          \[\leadsto e^{m \cdot \color{blue}{\left(m \cdot -0.25\right)}} \]
      14. Simplified98.3%

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

      if -9.2000000000000003e-4 < m < -7.20000000000000031e-300

      1. Initial program 85.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.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. Simplified95.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 M around inf

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

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

          \[\leadsto \cos M \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
      8. Simplified72.7%

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

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

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

        if -7.20000000000000031e-300 < 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 K around 0

          \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        8. Simplified25.8%

          \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
        9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
          12. distribute-lft-neg-inN/A

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

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

            \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
        11. Simplified87.6%

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

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

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

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

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

            \[\leadsto e^{\color{blue}{\left(n \cdot n\right)} \cdot -0.25} \]
        14. Simplified56.7%

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

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

      Alternative 4: 65.9% accurate, 2.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 2.8 \cdot 10^{-177}:\\ \;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;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 (<= n 2.8e-177)
         (exp (* m (* m -0.25)))
         (if (<= n 54.0) (exp (* M (- M))) (exp (* -0.25 (* n n))))))
      double code(double K, double m, double n, double M, double l) {
      	double tmp;
      	if (n <= 2.8e-177) {
      		tmp = exp((m * (m * -0.25)));
      	} else if (n <= 54.0) {
      		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 (n <= 2.8d-177) then
              tmp = exp((m * (m * (-0.25d0))))
          else if (n <= 54.0d0) 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 (n <= 2.8e-177) {
      		tmp = Math.exp((m * (m * -0.25)));
      	} else if (n <= 54.0) {
      		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 n <= 2.8e-177:
      		tmp = math.exp((m * (m * -0.25)))
      	elif n <= 54.0:
      		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 (n <= 2.8e-177)
      		tmp = exp(Float64(m * Float64(m * -0.25)));
      	elseif (n <= 54.0)
      		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 (n <= 2.8e-177)
      		tmp = exp((m * (m * -0.25)));
      	elseif (n <= 54.0)
      		tmp = exp((M * -M));
      	else
      		tmp = exp((-0.25 * (n * n)));
      	end
      	tmp_2 = tmp;
      end
      
      code[K_, m_, n_, M_, l_] := If[LessEqual[n, 2.8e-177], N[Exp[N[(m * N[(m * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 54.0], 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}\;n \leq 2.8 \cdot 10^{-177}:\\
      \;\;\;\;e^{m \cdot \left(m \cdot -0.25\right)}\\
      
      \mathbf{elif}\;n \leq 54:\\
      \;\;\;\;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 n < 2.79999999999999987e-177

        1. Initial program 80.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}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        8. Simplified31.0%

          \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
        9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
          12. distribute-lft-neg-inN/A

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

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

            \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
        11. Simplified89.6%

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

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

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

            \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
          3. associate-*r*N/A

            \[\leadsto e^{\color{blue}{m \cdot \left(m \cdot \frac{-1}{4}\right)}} \]
          4. *-commutativeN/A

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

            \[\leadsto e^{\color{blue}{m \cdot \left(\frac{-1}{4} \cdot m\right)}} \]
          6. *-commutativeN/A

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

            \[\leadsto e^{m \cdot \color{blue}{\left(m \cdot -0.25\right)}} \]
        14. Simplified59.3%

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

        if 2.79999999999999987e-177 < n < 54

        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.f6492.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. Simplified92.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 inf

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

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

            \[\leadsto \cos M \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
        8. Simplified65.4%

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

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

            \[\leadsto \color{blue}{1} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\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. lower-neg.f64N/A

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

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

              \[\leadsto 1 \cdot e^{-\color{blue}{M \cdot M}} \]
          4. Simplified63.1%

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

          if 54 < n

          1. Initial program 66.7%

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

            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

              \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
          8. Simplified15.0%

            \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
          9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
            12. distribute-lft-neg-inN/A

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

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

              \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
          11. Simplified100.0%

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(n \cdot n\right)} \cdot -0.25} \]
          14. Simplified98.4%

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

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

        Alternative 5: 68.4% accurate, 2.9× speedup?

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

          1. Initial program 69.6%

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

            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

              \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
          8. Simplified20.3%

            \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
          9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
            12. distribute-lft-neg-inN/A

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

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

              \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
          11. Simplified95.0%

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

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

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

              \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
            3. associate-*r*N/A

              \[\leadsto e^{\color{blue}{m \cdot \left(m \cdot \frac{-1}{4}\right)}} \]
            4. *-commutativeN/A

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

              \[\leadsto e^{\color{blue}{m \cdot \left(\frac{-1}{4} \cdot m\right)}} \]
            6. *-commutativeN/A

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

              \[\leadsto e^{m \cdot \color{blue}{\left(m \cdot -0.25\right)}} \]
          14. Simplified92.9%

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

          if -9.2000000000000003e-4 < m < 1.7499999999999999e-47

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

            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

              \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
          8. Simplified32.6%

            \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
          9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
            12. distribute-lft-neg-inN/A

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

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

              \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
          11. Simplified78.6%

            \[\leadsto \color{blue}{e^{\mathsf{fma}\left(-0.25, \left(m + n\right) \cdot \left(m + n\right), \left|m - n\right| - \ell\right)}} \]
          12. Taylor expanded in l around inf

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

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
            2. lower-neg.f6447.3

              \[\leadsto e^{\color{blue}{-\ell}} \]
          14. Simplified47.3%

            \[\leadsto e^{\color{blue}{-\ell}} \]
        3. Recombined 2 regimes into one program.
        4. Add Preprocessing

        Alternative 6: 65.5% accurate, 3.1× speedup?

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

          1. Initial program 79.4%

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

            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

              \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
          8. Simplified29.3%

            \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
          9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
            12. distribute-lft-neg-inN/A

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

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
            3. associate-*r*N/A

              \[\leadsto e^{\color{blue}{m \cdot \left(m \cdot \frac{-1}{4}\right)}} \]
            4. *-commutativeN/A

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

              \[\leadsto e^{\color{blue}{m \cdot \left(\frac{-1}{4} \cdot m\right)}} \]
            6. *-commutativeN/A

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

              \[\leadsto e^{m \cdot \color{blue}{\left(m \cdot -0.25\right)}} \]
          14. Simplified56.9%

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

          if 1.7e-16 < n

          1. Initial program 68.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}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

              \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
          8. Simplified15.9%

            \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
          9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
            12. distribute-lft-neg-inN/A

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

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

              \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
          11. Simplified96.9%

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left(n \cdot n\right)} \cdot -0.25} \]
          14. Simplified95.3%

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

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

        Alternative 7: 10.2% accurate, 3.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\\ \mathbf{if}\;\ell \leq -9 \cdot 10^{+116}:\\ \;\;\;\;\mathsf{fma}\left(\ell, t\_0 \cdot \mathsf{fma}\left(0.5, \ell, -1\right), t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;\cos M\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (let* ((t_0 (fma (* -0.125 (* K K)) (* (+ m n) (+ m n)) 1.0)))
           (if (<= l -9e+116) (fma l (* t_0 (fma 0.5 l -1.0)) t_0) (cos M))))
        double code(double K, double m, double n, double M, double l) {
        	double t_0 = fma((-0.125 * (K * K)), ((m + n) * (m + n)), 1.0);
        	double tmp;
        	if (l <= -9e+116) {
        		tmp = fma(l, (t_0 * fma(0.5, l, -1.0)), t_0);
        	} else {
        		tmp = cos(M);
        	}
        	return tmp;
        }
        
        function code(K, m, n, M, l)
        	t_0 = fma(Float64(-0.125 * Float64(K * K)), Float64(Float64(m + n) * Float64(m + n)), 1.0)
        	tmp = 0.0
        	if (l <= -9e+116)
        		tmp = fma(l, Float64(t_0 * fma(0.5, l, -1.0)), t_0);
        	else
        		tmp = cos(M);
        	end
        	return tmp
        end
        
        code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[l, -9e+116], N[(l * N[(t$95$0 * N[(0.5 * l + -1.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], N[Cos[M], $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\\
        \mathbf{if}\;\ell \leq -9 \cdot 10^{+116}:\\
        \;\;\;\;\mathsf{fma}\left(\ell, t\_0 \cdot \mathsf{fma}\left(0.5, \ell, -1\right), t\_0\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;\cos M\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if l < -9.00000000000000032e116

          1. Initial program 79.4%

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

            \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

              \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
          8. Simplified26.7%

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

            \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \cdot \mathsf{fma}\left(\frac{-1}{8}, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
          10. Step-by-step derivation
            1. neg-mul-1N/A

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

              \[\leadsto e^{\color{blue}{-\ell}} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
          11. Simplified21.6%

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

            \[\leadsto \color{blue}{1 + \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right) + \ell \cdot \left(-1 \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right) + \frac{1}{2} \cdot \left(\ell \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)\right)\right)\right)} \]
          13. Step-by-step derivation
            1. associate-+r+N/A

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, -1 \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right) + \frac{1}{2} \cdot \left(\ell \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)\right), 1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
          14. Simplified21.6%

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

          if -9.00000000000000032e116 < l

          1. Initial program 76.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 M around inf

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \cos \left(\frac{1}{2} \cdot \color{blue}{\left(K \cdot \left(m + n\right)\right)} - M\right) \]
            5. lower-+.f647.2

              \[\leadsto \cos \left(0.5 \cdot \left(K \cdot \color{blue}{\left(m + n\right)}\right) - M\right) \]
          11. Simplified7.2%

            \[\leadsto \color{blue}{\cos \left(0.5 \cdot \left(K \cdot \left(m + n\right)\right) - M\right)} \]
          12. Taylor expanded in K around 0

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

              \[\leadsto \color{blue}{\cos M} \]
            2. lower-cos.f647.5

              \[\leadsto \color{blue}{\cos M} \]
          14. Simplified7.5%

            \[\leadsto \color{blue}{\cos M} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification9.4%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -9 \cdot 10^{+116}:\\ \;\;\;\;\mathsf{fma}\left(\ell, \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right) \cdot \mathsf{fma}\left(0.5, \ell, -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\cos M\\ \end{array} \]
        5. Add Preprocessing

        Alternative 8: 35.6% 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 76.6%

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

          \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        8. Simplified26.0%

          \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right)} \]
        9. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)\right) + \left(\left|m - n\right| - \ell\right)}} \]
          12. distribute-lft-neg-inN/A

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

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

            \[\leadsto e^{\color{blue}{\mathsf{fma}\left(\frac{-1}{4}, {\left(m + n\right)}^{2}, \left|m - n\right| - \ell\right)}} \]
        11. Simplified87.5%

          \[\leadsto \color{blue}{e^{\mathsf{fma}\left(-0.25, \left(m + n\right) \cdot \left(m + n\right), \left|m - n\right| - \ell\right)}} \]
        12. Taylor expanded in l around inf

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

            \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
          2. lower-neg.f6435.0

            \[\leadsto e^{\color{blue}{-\ell}} \]
        14. Simplified35.0%

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

        Alternative 9: 9.0% accurate, 5.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\\ \mathsf{fma}\left(\ell, t\_0 \cdot \mathsf{fma}\left(0.5, \ell, -1\right), t\_0\right) \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (let* ((t_0 (fma (* -0.125 (* K K)) (* (+ m n) (+ m n)) 1.0)))
           (fma l (* t_0 (fma 0.5 l -1.0)) t_0)))
        double code(double K, double m, double n, double M, double l) {
        	double t_0 = fma((-0.125 * (K * K)), ((m + n) * (m + n)), 1.0);
        	return fma(l, (t_0 * fma(0.5, l, -1.0)), t_0);
        }
        
        function code(K, m, n, M, l)
        	t_0 = fma(Float64(-0.125 * Float64(K * K)), Float64(Float64(m + n) * Float64(m + n)), 1.0)
        	return fma(l, Float64(t_0 * fma(0.5, l, -1.0)), t_0)
        end
        
        code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, N[(l * N[(t$95$0 * N[(0.5 * l + -1.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\\
        \mathsf{fma}\left(\ell, t\_0 \cdot \mathsf{fma}\left(0.5, \ell, -1\right), t\_0\right)
        \end{array}
        \end{array}
        
        Derivation
        1. Initial program 76.6%

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

          \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        8. Simplified26.0%

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

          \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \cdot \mathsf{fma}\left(\frac{-1}{8}, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
        10. Step-by-step derivation
          1. neg-mul-1N/A

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

            \[\leadsto e^{\color{blue}{-\ell}} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
        11. Simplified15.1%

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

          \[\leadsto \color{blue}{1 + \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right) + \ell \cdot \left(-1 \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right) + \frac{1}{2} \cdot \left(\ell \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)\right)\right)\right)} \]
        13. Step-by-step derivation
          1. associate-+r+N/A

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, -1 \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right) + \frac{1}{2} \cdot \left(\ell \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)\right), 1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        14. Simplified7.5%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(n + m\right) \cdot \left(n + m\right), 1\right) \cdot \mathsf{fma}\left(0.5, \ell, -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(n + m\right) \cdot \left(n + m\right), 1\right)\right)} \]
        15. Final simplification7.5%

          \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right) \cdot \mathsf{fma}\left(0.5, \ell, -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\right) \]
        16. Add Preprocessing

        Alternative 10: 6.8% accurate, 5.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(m + n\right) \cdot \left(m + n\right)\\ \mathsf{fma}\left(\ell, \mathsf{fma}\left(0.125, \left(K \cdot K\right) \cdot t\_0, -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), t\_0, 1\right)\right) \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (let* ((t_0 (* (+ m n) (+ m n))))
           (fma l (fma 0.125 (* (* K K) t_0) -1.0) (fma (* -0.125 (* K K)) t_0 1.0))))
        double code(double K, double m, double n, double M, double l) {
        	double t_0 = (m + n) * (m + n);
        	return fma(l, fma(0.125, ((K * K) * t_0), -1.0), fma((-0.125 * (K * K)), t_0, 1.0));
        }
        
        function code(K, m, n, M, l)
        	t_0 = Float64(Float64(m + n) * Float64(m + n))
        	return fma(l, fma(0.125, Float64(Float64(K * K) * t_0), -1.0), fma(Float64(-0.125 * Float64(K * K)), t_0, 1.0))
        end
        
        code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]}, N[(l * N[(0.125 * N[(N[(K * K), $MachinePrecision] * t$95$0), $MachinePrecision] + -1.0), $MachinePrecision] + N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \left(m + n\right) \cdot \left(m + n\right)\\
        \mathsf{fma}\left(\ell, \mathsf{fma}\left(0.125, \left(K \cdot K\right) \cdot t\_0, -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), t\_0, 1\right)\right)
        \end{array}
        \end{array}
        
        Derivation
        1. Initial program 76.6%

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

          \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        8. Simplified26.0%

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

          \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \cdot \mathsf{fma}\left(\frac{-1}{8}, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
        10. Step-by-step derivation
          1. neg-mul-1N/A

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

            \[\leadsto e^{\color{blue}{-\ell}} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
        11. Simplified15.1%

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

          \[\leadsto \color{blue}{1 + \left(-1 \cdot \left(\ell \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)\right) + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        13. Step-by-step derivation
          1. +-commutativeN/A

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

            \[\leadsto \color{blue}{-1 \cdot \left(\ell \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)\right) + \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right) + 1\right)} \]
          3. mul-1-negN/A

            \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\ell \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)\right)\right)} + \left(\frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right) + 1\right) \]
          4. distribute-rgt-neg-inN/A

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, -1 \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right), 1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        14. Simplified5.5%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \mathsf{fma}\left(0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(n + m\right) \cdot \left(n + m\right), 1\right)\right)} \]
        15. Final simplification5.5%

          \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(0.125, \left(K \cdot K\right) \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right), -1\right), \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)\right) \]
        16. Add Preprocessing

        Alternative 11: 6.9% accurate, 12.8× speedup?

        \[\begin{array}{l} \\ \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right) \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (fma (* -0.125 (* K K)) (* (+ m n) (+ m n)) 1.0))
        double code(double K, double m, double n, double M, double l) {
        	return fma((-0.125 * (K * K)), ((m + n) * (m + n)), 1.0);
        }
        
        function code(K, m, n, M, l)
        	return fma(Float64(-0.125 * Float64(K * K)), Float64(Float64(m + n) * Float64(m + n)), 1.0)
        end
        
        code[K_, m_, n_, M_, l_] := N[(N[(-0.125 * N[(K * K), $MachinePrecision]), $MachinePrecision] * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right)
        \end{array}
        
        Derivation
        1. Initial program 76.6%

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

          \[\leadsto \color{blue}{\left(\cos \left(\mathsf{neg}\left(M\right)\right) + K \cdot \left(\frac{-1}{8} \cdot \left(K \cdot \left(\cos \left(\mathsf{neg}\left(M\right)\right) \cdot {\left(m + n\right)}^{2}\right)\right) - \frac{1}{2} \cdot \left(\sin \left(\mathsf{neg}\left(M\right)\right) \cdot \left(m + n\right)\right)\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. +-commutativeN/A

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

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

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

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

            \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \cdot \left(1 + \frac{-1}{8} \cdot \left({K}^{2} \cdot {\left(m + n\right)}^{2}\right)\right)} \]
        8. Simplified26.0%

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

          \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \cdot \mathsf{fma}\left(\frac{-1}{8}, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
        10. Step-by-step derivation
          1. neg-mul-1N/A

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

            \[\leadsto e^{\color{blue}{-\ell}} \cdot \mathsf{fma}\left(-0.125, \left(\left(n + m\right) \cdot \left(n + m\right)\right) \cdot \left(K \cdot K\right), 1\right) \]
        11. Simplified15.1%

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(K \cdot K\right), \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, 1\right) \]
          9. +-commutativeN/A

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

            \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(K \cdot K\right), \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), 1\right) \]
          11. +-commutativeN/A

            \[\leadsto \mathsf{fma}\left(\frac{-1}{8} \cdot \left(K \cdot K\right), \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, 1\right) \]
          12. lower-+.f645.2

            \[\leadsto \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, 1\right) \]
        14. Simplified5.2%

          \[\leadsto \color{blue}{\mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(n + m\right) \cdot \left(n + m\right), 1\right)} \]
        15. Final simplification5.2%

          \[\leadsto \mathsf{fma}\left(-0.125 \cdot \left(K \cdot K\right), \left(m + n\right) \cdot \left(m + n\right), 1\right) \]
        16. Add Preprocessing

        Reproduce

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