Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.4% → 96.8%
Time: 13.6s
Alternatives: 13
Speedup: 2.8×

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 13 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.4% 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.8% 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 80.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.1

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

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

    \[\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: 96.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|m - n\right|\\ t_1 := t\_0 - \ell\\ t_2 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\ t_3 := \left(m + n\right) \cdot \left(m + n\right)\\ \mathbf{if}\;e^{t\_1 - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot t\_2 \leq 0.6:\\ \;\;\;\;t\_2 \cdot e^{t\_1 - M \cdot \mathsf{fma}\left(M, \frac{n + \mathsf{fma}\left(-0.25, \frac{t\_3}{M}, m\right)}{-M}, M\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{t\_0 - \mathsf{fma}\left(0.25, t\_3, \ell\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (fabs (- m n)))
        (t_1 (- t_0 l))
        (t_2 (cos (- (/ (* K (+ m n)) 2.0) M)))
        (t_3 (* (+ m n) (+ m n))))
   (if (<= (* (exp (- t_1 (pow (- (/ (+ m n) 2.0) M) 2.0))) t_2) 0.6)
     (*
      t_2
      (exp (- t_1 (* M (fma M (/ (+ n (fma -0.25 (/ t_3 M) m)) (- M)) M)))))
     (exp (- t_0 (fma 0.25 t_3 l))))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = fabs((m - n));
	double t_1 = t_0 - l;
	double t_2 = cos((((K * (m + n)) / 2.0) - M));
	double t_3 = (m + n) * (m + n);
	double tmp;
	if ((exp((t_1 - pow((((m + n) / 2.0) - M), 2.0))) * t_2) <= 0.6) {
		tmp = t_2 * exp((t_1 - (M * fma(M, ((n + fma(-0.25, (t_3 / M), m)) / -M), M))));
	} else {
		tmp = exp((t_0 - fma(0.25, t_3, l)));
	}
	return tmp;
}
function code(K, m, n, M, l)
	t_0 = abs(Float64(m - n))
	t_1 = Float64(t_0 - l)
	t_2 = cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M))
	t_3 = Float64(Float64(m + n) * Float64(m + n))
	tmp = 0.0
	if (Float64(exp(Float64(t_1 - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) * t_2) <= 0.6)
		tmp = Float64(t_2 * exp(Float64(t_1 - Float64(M * fma(M, Float64(Float64(n + fma(-0.25, Float64(t_3 / M), m)) / Float64(-M)), M)))));
	else
		tmp = exp(Float64(t_0 - fma(0.25, t_3, l)));
	end
	return tmp
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - l), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Exp[N[(t$95$1 - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision], 0.6], N[(t$95$2 * N[Exp[N[(t$95$1 - N[(M * N[(M * N[(N[(n + N[(-0.25 * N[(t$95$3 / M), $MachinePrecision] + m), $MachinePrecision]), $MachinePrecision] / (-M)), $MachinePrecision] + M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * t$95$3 + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
t_1 := t\_0 - \ell\\
t_2 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
t_3 := \left(m + n\right) \cdot \left(m + n\right)\\
\mathbf{if}\;e^{t\_1 - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot t\_2 \leq 0.6:\\
\;\;\;\;t\_2 \cdot e^{t\_1 - M \cdot \mathsf{fma}\left(M, \frac{n + \mathsf{fma}\left(-0.25, \frac{t\_3}{M}, m\right)}{-M}, M\right)}\\

\mathbf{else}:\\
\;\;\;\;e^{t\_0 - \mathsf{fma}\left(0.25, t\_3, \ell\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < 0.599999999999999978

    1. Initial program 97.9%

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

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(\mathsf{neg}\left(\color{blue}{{M}^{2} \cdot \left(1 + -1 \cdot \frac{m + \left(n + \frac{-1}{4} \cdot \frac{{\left(m + n\right)}^{2}}{M}\right)}{M}\right)}\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}{\left(M \cdot M\right)} \cdot \left(1 + -1 \cdot \frac{m + \left(n + \frac{-1}{4} \cdot \frac{{\left(m + n\right)}^{2}}{M}\right)}{M}\right)\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. associate-*l*N/A

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

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

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

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

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

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

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

    if 0.599999999999999978 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n))))))

    1. Initial program 30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified94.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)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.0%

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

Alternative 3: 96.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
t_1 := \left|m - n\right|\\
\mathbf{if}\;e^{\left(t\_1 - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot t\_0 \leq 0.6:\\
\;\;\;\;t\_0 \cdot e^{M \cdot \mathsf{fma}\left(M, \frac{\left(m + n\right) + \frac{t\_1 - \mathsf{fma}\left(m + n, \left(m + n\right) \cdot 0.25, \ell\right)}{M}}{M}, -M\right)}\\

\mathbf{else}:\\
\;\;\;\;e^{t\_1 - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < 0.599999999999999978

    1. Initial program 97.9%

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

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

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

    if 0.599999999999999978 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n))))))

    1. Initial program 30.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified94.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)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.0%

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

Alternative 4: 95.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{if}\;M \leq -5.15 \cdot 10^{+64}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 27:\\ \;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (* (cos M) (exp (* M (- M))))))
   (if (<= M -5.15e+64)
     t_0
     (if (<= M 27.0)
       (exp (- (fabs (- m n)) (fma 0.25 (* (+ m n) (+ m n)) l)))
       t_0))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = cos(M) * exp((M * -M));
	double tmp;
	if (M <= -5.15e+64) {
		tmp = t_0;
	} else if (M <= 27.0) {
		tmp = exp((fabs((m - n)) - fma(0.25, ((m + n) * (m + n)), l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(K, m, n, M, l)
	t_0 = Float64(cos(M) * exp(Float64(M * Float64(-M))))
	tmp = 0.0
	if (M <= -5.15e+64)
		tmp = t_0;
	elseif (M <= 27.0)
		tmp = exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l)));
	else
		tmp = t_0;
	end
	return tmp
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -5.15e+64], t$95$0, If[LessEqual[M, 27.0], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -5.15 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < -5.15000000000000009e64 or 27 < M

    1. Initial program 79.7%

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

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

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

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

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

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

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

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

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

    if -5.15000000000000009e64 < M < 27

    1. Initial program 81.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.f6493.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. Simplified93.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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 60.6% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -53:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;m \leq -6.6 \cdot 10^{-189}:\\ \;\;\;\;e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{fma}\left(-0.25, n \cdot n, \left|m - n\right|\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (<= m -53.0)
   (exp (* -0.25 (* m m)))
   (if (<= m -6.6e-189) (exp (- l)) (exp (fma -0.25 (* n n) (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -53.0) {
		tmp = exp((-0.25 * (m * m)));
	} else if (m <= -6.6e-189) {
		tmp = exp(-l);
	} else {
		tmp = exp(fma(-0.25, (n * n), fabs((m - n))));
	}
	return tmp;
}
function code(K, m, n, M, l)
	tmp = 0.0
	if (m <= -53.0)
		tmp = exp(Float64(-0.25 * Float64(m * m)));
	elseif (m <= -6.6e-189)
		tmp = exp(Float64(-l));
	else
		tmp = exp(fma(-0.25, Float64(n * n), abs(Float64(m - n))));
	end
	return tmp
end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -53.0], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, -6.6e-189], N[Exp[(-l)], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision] + N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -53:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\

\mathbf{elif}\;m \leq -6.6 \cdot 10^{-189}:\\
\;\;\;\;e^{-\ell}\\

\mathbf{else}:\\
\;\;\;\;e^{\mathsf{fma}\left(-0.25, n \cdot n, \left|m - n\right|\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if m < -53

    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.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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified100.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)}} \]
    9. Taylor expanded in m around inf

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

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

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

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

        \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
    11. Simplified100.0%

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

    if -53 < m < -6.6000000000000002e-189

    1. Initial program 88.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}{\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified83.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)}} \]
    9. Taylor expanded in l around inf

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

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

        \[\leadsto e^{\color{blue}{-\ell}} \]
    11. Simplified51.4%

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

    if -6.6000000000000002e-189 < m

    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}{\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.2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified82.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)}} \]
    9. Taylor expanded in n around inf

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \color{blue}{n \cdot n}, \ell\right)} \]
    11. Simplified63.7%

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

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

        \[\leadsto \color{blue}{e^{\left|n - m\right| - \frac{1}{4} \cdot {n}^{2}}} \]
      2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{fma}\left(-0.25, n \cdot n, \left|\color{blue}{n - m}\right|\right)} \]
    14. Simplified44.9%

      \[\leadsto \color{blue}{e^{\mathsf{fma}\left(-0.25, n \cdot n, \left|n - m\right|\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification59.6%

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

Alternative 6: 73.4% accurate, 2.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -56:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, n \cdot n, \ell\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (<= m -56.0)
   (exp (* -0.25 (* m m)))
   (exp (- (fabs (- m n)) (fma 0.25 (* n n) l)))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -56.0) {
		tmp = exp((-0.25 * (m * m)));
	} else {
		tmp = exp((fabs((m - n)) - fma(0.25, (n * n), l)));
	}
	return tmp;
}
function code(K, m, n, M, l)
	tmp = 0.0
	if (m <= -56.0)
		tmp = exp(Float64(-0.25 * Float64(m * m)));
	else
		tmp = exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(n * n), l)));
	end
	return tmp
end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -56.0], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(n * n), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -56:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\

\mathbf{else}:\\
\;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, n \cdot n, \ell\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -56

    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.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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified100.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)}} \]
    9. Taylor expanded in m around inf

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

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

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

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

        \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
    11. Simplified100.0%

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

    if -56 < m

    1. Initial program 81.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}{\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.f6496.1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified82.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)}} \]
    9. Taylor expanded in n around inf

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \color{blue}{n \cdot n}, \ell\right)} \]
    11. Simplified67.5%

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

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

Alternative 7: 86.3% accurate, 2.8× speedup?

\[\begin{array}{l} \\ e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (exp (- (fabs (- m n)) (fma 0.25 (* (+ m n) (+ m n)) l))))
double code(double K, double m, double n, double M, double l) {
	return exp((fabs((m - n)) - fma(0.25, ((m + n) * (m + n)), l)));
}
function code(K, m, n, M, l)
	return exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l)))
end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}
\end{array}
Derivation
  1. Initial program 80.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.1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
  8. Simplified86.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)}} \]
  9. Final simplification86.8%

    \[\leadsto e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)} \]
  10. Add Preprocessing

Alternative 8: 63.2% accurate, 2.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;m \leq -53:\\
\;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\

\mathbf{elif}\;m \leq -6.6 \cdot 10^{-189}:\\
\;\;\;\;e^{-\ell}\\

\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 < -53

    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.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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified100.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)}} \]
    9. Taylor expanded in m around inf

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

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

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

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

        \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
    11. Simplified100.0%

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

    if -53 < m < -6.6000000000000002e-189

    1. Initial program 88.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}{\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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified83.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)}} \]
    9. Taylor expanded in l around inf

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

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

        \[\leadsto e^{\color{blue}{-\ell}} \]
    11. Simplified51.4%

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

    if -6.6000000000000002e-189 < m

    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}{\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.2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified82.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)}} \]
    9. Taylor expanded in n around inf

      \[\leadsto e^{\color{blue}{\frac{-1}{4} \cdot {n}^{2}}} \]
    10. 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-*.f6449.0

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

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

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

Alternative 9: 68.5% accurate, 2.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{if}\;m \leq -53:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;m \leq 54:\\ \;\;\;\;e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (exp (* -0.25 (* m m)))))
   (if (<= m -53.0) t_0 (if (<= m 54.0) (exp (- l)) t_0))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = exp((-0.25 * (m * m)));
	double tmp;
	if (m <= -53.0) {
		tmp = t_0;
	} else if (m <= 54.0) {
		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(((-0.25d0) * (m * m)))
    if (m <= (-53.0d0)) then
        tmp = t_0
    else if (m <= 54.0d0) 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((-0.25 * (m * m)));
	double tmp;
	if (m <= -53.0) {
		tmp = t_0;
	} else if (m <= 54.0) {
		tmp = Math.exp(-l);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(K, m, n, M, l):
	t_0 = math.exp((-0.25 * (m * m)))
	tmp = 0
	if m <= -53.0:
		tmp = t_0
	elif m <= 54.0:
		tmp = math.exp(-l)
	else:
		tmp = t_0
	return tmp
function code(K, m, n, M, l)
	t_0 = exp(Float64(-0.25 * Float64(m * m)))
	tmp = 0.0
	if (m <= -53.0)
		tmp = t_0;
	elseif (m <= 54.0)
		tmp = exp(Float64(-l));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	t_0 = exp((-0.25 * (m * m)));
	tmp = 0.0;
	if (m <= -53.0)
		tmp = t_0;
	elseif (m <= 54.0)
		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[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -53.0], t$95$0, If[LessEqual[m, 54.0], N[Exp[(-l)], $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{if}\;m \leq -53:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;m \leq 54:\\
\;\;\;\;e^{-\ell}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -53 or 54 < m

    1. Initial program 75.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.f6499.2

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified97.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)}} \]
    9. Taylor expanded in m around inf

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

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

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

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

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

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

    if -53 < m < 54

    1. Initial program 85.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.f6494.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. Simplified94.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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified76.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)}} \]
    9. Taylor expanded in l around inf

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

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

        \[\leadsto e^{\color{blue}{-\ell}} \]
    11. Simplified43.7%

      \[\leadsto e^{\color{blue}{-\ell}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -53:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;m \leq 54:\\ \;\;\;\;e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 34.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 80.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.1

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
  8. Simplified86.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)}} \]
  9. Taylor expanded in l around inf

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

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

      \[\leadsto e^{\color{blue}{-\ell}} \]
  11. Simplified36.2%

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

Alternative 11: 9.0% accurate, 8.0× speedup?

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

\\
\mathsf{fma}\left(K \cdot K, \left(m \cdot m\right) \cdot -0.125, 1\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)
\end{array}
Derivation
  1. Initial program 80.6%

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\frac{1}{2} \cdot \color{blue}{\left(m \cdot K\right)}\right) \cdot e^{\mathsf{neg}\left(\ell\right)} \]
    3. lower-*.f6436.3

      \[\leadsto \cos \left(0.5 \cdot \color{blue}{\left(m \cdot K\right)}\right) \cdot e^{-\ell} \]
  8. Simplified36.3%

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

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

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

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) - 1, 1\right)} \]
    3. sub-negN/A

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) + \left(\mathsf{neg}\left(1\right)\right)}, 1\right) \]
    4. metadata-evalN/A

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

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{2} + \frac{-1}{6} \cdot \ell, -1\right)}, 1\right) \]
    6. +-commutativeN/A

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\frac{-1}{6} \cdot \ell + \frac{1}{2}}, -1\right), 1\right) \]
    7. *-commutativeN/A

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

      \[\leadsto \cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right)}, -1\right), 1\right) \]
  11. Simplified10.1%

    \[\leadsto \cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)} \]
  12. Taylor expanded in m around 0

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(K \cdot K, \frac{-1}{8} \cdot \color{blue}{\left(m \cdot m\right)}, 1\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \frac{-1}{6}, \frac{1}{2}\right), -1\right), 1\right) \]
    10. lower-*.f648.9

      \[\leadsto \mathsf{fma}\left(K \cdot K, -0.125 \cdot \color{blue}{\left(m \cdot m\right)}, 1\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right) \]
  14. Simplified8.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(K \cdot K, -0.125 \cdot \left(m \cdot m\right), 1\right)} \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right) \]
  15. Final simplification8.9%

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

Alternative 12: 10.0% accurate, 18.9× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right) \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (fma l (fma l (fma l -0.16666666666666666 0.5) -1.0) 1.0))
double code(double K, double m, double n, double M, double l) {
	return fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0);
}
function code(K, m, n, M, l)
	return fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0)
end
code[K_, m_, n_, M_, l_] := N[(l * N[(l * N[(l * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)
\end{array}
Derivation
  1. Initial program 80.6%

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\frac{1}{2} \cdot \color{blue}{\left(m \cdot K\right)}\right) \cdot e^{\mathsf{neg}\left(\ell\right)} \]
    3. lower-*.f6436.3

      \[\leadsto \cos \left(0.5 \cdot \color{blue}{\left(m \cdot K\right)}\right) \cdot e^{-\ell} \]
  8. Simplified36.3%

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

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

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

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) - 1, 1\right)} \]
    3. sub-negN/A

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) + \left(\mathsf{neg}\left(1\right)\right)}, 1\right) \]
    4. metadata-evalN/A

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

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{2} + \frac{-1}{6} \cdot \ell, -1\right)}, 1\right) \]
    6. +-commutativeN/A

      \[\leadsto \cos \left(\frac{1}{2} \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\frac{-1}{6} \cdot \ell + \frac{1}{2}}, -1\right), 1\right) \]
    7. *-commutativeN/A

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

      \[\leadsto \cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right)}, -1\right), 1\right) \]
  11. Simplified10.1%

    \[\leadsto \cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)} \]
  12. Taylor expanded in m around 0

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) - 1, 1\right)} \]
    3. sub-negN/A

      \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) + \left(\mathsf{neg}\left(1\right)\right)}, 1\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(\ell, \ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) + \color{blue}{-1}, 1\right) \]
    5. lower-fma.f64N/A

      \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, \frac{1}{2} + \frac{-1}{6} \cdot \ell, -1\right)}, 1\right) \]
    6. +-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\frac{-1}{6} \cdot \ell + \frac{1}{2}}, -1\right), 1\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{-1}{6}} + \frac{1}{2}, -1\right), 1\right) \]
    8. lower-fma.f649.3

      \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right)}, -1\right), 1\right) \]
  14. Simplified9.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)} \]
  15. Add Preprocessing

Alternative 13: 7.2% accurate, 359.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
	return 1.0;
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
	return 1.0;
}
def code(K, m, n, M, l):
	return 1.0
function code(K, m, n, M, l)
	return 1.0
end
function tmp = code(K, m, n, M, l)
	tmp = 1.0;
end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 80.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 n around inf

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos M} \]
  11. Simplified5.8%

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

    \[\leadsto \color{blue}{1} \]
  13. Step-by-step derivation
    1. Simplified5.8%

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

    Reproduce

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