Average Error: 15.4 → 2.0
Time: 21.6s
Precision: binary64
Cost: 20360
\[ \begin{array}{c}[m, n] = \mathsf{sort}([m, n])\\ \end{array} \]
\[\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)} \]
\[\begin{array}{l} t_0 := m - \left(n + \ell\right)\\ \mathbf{if}\;\ell \leq -5 \cdot 10^{+165}:\\ \;\;\;\;\cos M \cdot e^{\ell}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-51}:\\ \;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{t_0 - {\left(m \cdot 0.5 - M\right)}^{2}}\\ \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)))))))
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (- m (+ n l))))
   (if (<= l -5e+165)
     (* (cos M) (exp l))
     (if (<= l -2e-51)
       (* (cos M) (exp (- t_0 (* M M))))
       (* (cos M) (exp (- t_0 (pow (- (* m 0.5) M) 2.0))))))))
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)))));
}
double code(double K, double m, double n, double M, double l) {
	double t_0 = m - (n + l);
	double tmp;
	if (l <= -5e+165) {
		tmp = cos(M) * exp(l);
	} else if (l <= -2e-51) {
		tmp = cos(M) * exp((t_0 - (M * M)));
	} else {
		tmp = cos(M) * exp((t_0 - pow(((m * 0.5) - M), 2.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
    code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
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 = m - (n + l)
    if (l <= (-5d+165)) then
        tmp = cos(m_1) * exp(l)
    else if (l <= (-2d-51)) then
        tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
    else
        tmp = cos(m_1) * exp((t_0 - (((m * 0.5d0) - m_1) ** 2.0d0)))
    end if
    code = tmp
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)))));
}
public static double code(double K, double m, double n, double M, double l) {
	double t_0 = m - (n + l);
	double tmp;
	if (l <= -5e+165) {
		tmp = Math.cos(M) * Math.exp(l);
	} else if (l <= -2e-51) {
		tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
	} else {
		tmp = Math.cos(M) * Math.exp((t_0 - Math.pow(((m * 0.5) - M), 2.0)));
	}
	return tmp;
}
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)))))
def code(K, m, n, M, l):
	t_0 = m - (n + l)
	tmp = 0
	if l <= -5e+165:
		tmp = math.cos(M) * math.exp(l)
	elif l <= -2e-51:
		tmp = math.cos(M) * math.exp((t_0 - (M * M)))
	else:
		tmp = math.cos(M) * math.exp((t_0 - math.pow(((m * 0.5) - M), 2.0)))
	return tmp
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 code(K, m, n, M, l)
	t_0 = Float64(m - Float64(n + l))
	tmp = 0.0
	if (l <= -5e+165)
		tmp = Float64(cos(M) * exp(l));
	elseif (l <= -2e-51)
		tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M))));
	else
		tmp = Float64(cos(M) * exp(Float64(t_0 - (Float64(Float64(m * 0.5) - M) ^ 2.0))));
	end
	return tmp
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
function tmp_2 = code(K, m, n, M, l)
	t_0 = m - (n + l);
	tmp = 0.0;
	if (l <= -5e+165)
		tmp = cos(M) * exp(l);
	elseif (l <= -2e-51)
		tmp = cos(M) * exp((t_0 - (M * M)));
	else
		tmp = cos(M) * exp((t_0 - (((m * 0.5) - M) ^ 2.0)));
	end
	tmp_2 = tmp;
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]
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -5e+165], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -2e-51], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[Power[N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\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)}
\begin{array}{l}
t_0 := m - \left(n + \ell\right)\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{+165}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\

\mathbf{elif}\;\ell \leq -2 \cdot 10^{-51}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\

\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - {\left(m \cdot 0.5 - M\right)}^{2}}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 3 regimes
  2. if l < -4.9999999999999997e165

    1. Initial program 16.8

      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    2. Simplified16.5

      \[\leadsto \color{blue}{\cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}} \]
      Proof
      (*.f64 (cos.f64 (-.f64 (*.f64 (+.f64 m n) (/.f64 K 2)) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (+.f64 m n) K) 2)) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 K (+.f64 m n))) 2) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite=> associate--l-_binary64 (-.f64 (fabs.f64 (-.f64 m n)) (+.f64 l (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (fabs.f64 (-.f64 m n)) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2) l))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite=> associate--r+_binary64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (Rewrite<= unsub-neg_binary64 (+.f64 (fabs.f64 (-.f64 m n)) (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))) l))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= associate-+r-_binary64 (+.f64 (fabs.f64 (-.f64 m n)) (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= +-commutative_binary64 (+.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l) (fabs.f64 (-.f64 m n)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= associate--r-_binary64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n))))))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in l around inf 64.0

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

      \[\leadsto \cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
      Proof
      (neg.f64 l): 0 points increase in error, 0 points decrease in error
      (Rewrite=> neg-mul-1_binary64 (*.f64 -1 l)): 0 points increase in error, 0 points decrease in error
    5. Applied egg-rr16.5

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

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

      \[\leadsto \color{blue}{\cos M \cdot e^{\ell}} \]
      Proof
      (*.f64 (cos.f64 M) (exp.f64 l)): 0 points increase in error, 0 points decrease in error
      (*.f64 (Rewrite<= cos-neg_binary64 (cos.f64 (neg.f64 M))) (exp.f64 l)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= *-commutative_binary64 (*.f64 (exp.f64 l) (cos.f64 (neg.f64 M)))): 0 points increase in error, 0 points decrease in error

    if -4.9999999999999997e165 < l < -2e-51

    1. Initial program 15.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. Simplified15.6

      \[\leadsto \color{blue}{\cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}} \]
      Proof
      (*.f64 (cos.f64 (-.f64 (*.f64 (+.f64 m n) (/.f64 K 2)) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (+.f64 m n) K) 2)) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 K (+.f64 m n))) 2) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite=> associate--l-_binary64 (-.f64 (fabs.f64 (-.f64 m n)) (+.f64 l (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (fabs.f64 (-.f64 m n)) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2) l))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite=> associate--r+_binary64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (Rewrite<= unsub-neg_binary64 (+.f64 (fabs.f64 (-.f64 m n)) (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))) l))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= associate-+r-_binary64 (+.f64 (fabs.f64 (-.f64 m n)) (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= +-commutative_binary64 (+.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l) (fabs.f64 (-.f64 m n)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= associate--r-_binary64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n))))))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in K around 0 0.9

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

      \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
      Proof
      (cos.f64 M): 0 points increase in error, 0 points decrease in error
      (Rewrite<= cos-neg_binary64 (cos.f64 (neg.f64 M))): 0 points increase in error, 0 points decrease in error
    5. Taylor expanded in n around 0 14.9

      \[\leadsto \cos M \cdot e^{\color{blue}{\left|m - n\right| - \left({\left(0.5 \cdot m - M\right)}^{2} + \ell\right)}} \]
    6. Simplified2.1

      \[\leadsto \cos M \cdot e^{\color{blue}{\left(m - \left(n + \ell\right)\right) - {\left(0.5 \cdot m - M\right)}^{2}}} \]
      Proof
      (-.f64 (-.f64 m (+.f64 n l)) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= associate--l-_binary64 (-.f64 (-.f64 m n) l)) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (Rewrite<= unpow1_binary64 (pow.f64 (-.f64 m n) 1)) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (Rewrite=> sqr-pow_binary64 (*.f64 (pow.f64 (-.f64 m n) (/.f64 1 2)) (pow.f64 (-.f64 m n) (/.f64 1 2)))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 140 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (pow.f64 (-.f64 m n) (/.f64 1 2)) (pow.f64 (-.f64 m n) (/.f64 1 2))))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (fabs.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (-.f64 m n) 1))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 140 points decrease in error
      (-.f64 (-.f64 (fabs.f64 (Rewrite=> unpow1_binary64 (-.f64 m n))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate--r+_binary64 (-.f64 (fabs.f64 (-.f64 m n)) (+.f64 l (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (fabs.f64 (-.f64 m n)) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (-.f64 (*.f64 1/2 m) M) 2) l))): 0 points increase in error, 0 points decrease in error
    7. Taylor expanded in m around 0 3.4

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

      \[\leadsto \cos M \cdot e^{\left(m - \left(n + \ell\right)\right) - \color{blue}{M \cdot M}} \]
      Proof
      (*.f64 M M): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unpow2_binary64 (pow.f64 M 2)): 0 points increase in error, 0 points decrease in error

    if -2e-51 < l

    1. Initial program 15.2

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

      \[\leadsto \color{blue}{\cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}} \]
      Proof
      (*.f64 (cos.f64 (-.f64 (*.f64 (+.f64 m n) (/.f64 K 2)) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (+.f64 m n) K) 2)) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 K (+.f64 m n))) 2) M)) (exp.f64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) l) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite=> associate--l-_binary64 (-.f64 (fabs.f64 (-.f64 m n)) (+.f64 l (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (fabs.f64 (-.f64 m n)) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2) l))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite=> associate--r+_binary64 (-.f64 (-.f64 (fabs.f64 (-.f64 m n)) (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l)))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (Rewrite<= unsub-neg_binary64 (+.f64 (fabs.f64 (-.f64 m n)) (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)))) l))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= associate-+r-_binary64 (+.f64 (fabs.f64 (-.f64 m n)) (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= +-commutative_binary64 (+.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) l) (fabs.f64 (-.f64 m n)))))): 0 points increase in error, 0 points decrease in error
      (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (Rewrite<= associate--r-_binary64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n))))))): 0 points increase in error, 0 points decrease in error
    3. Taylor expanded in K around 0 1.7

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

      \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
      Proof
      (cos.f64 M): 0 points increase in error, 0 points decrease in error
      (Rewrite<= cos-neg_binary64 (cos.f64 (neg.f64 M))): 0 points increase in error, 0 points decrease in error
    5. Taylor expanded in n around 0 11.8

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

      \[\leadsto \cos M \cdot e^{\color{blue}{\left(m - \left(n + \ell\right)\right) - {\left(0.5 \cdot m - M\right)}^{2}}} \]
      Proof
      (-.f64 (-.f64 m (+.f64 n l)) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= associate--l-_binary64 (-.f64 (-.f64 m n) l)) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (Rewrite<= unpow1_binary64 (pow.f64 (-.f64 m n) 1)) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (Rewrite=> sqr-pow_binary64 (*.f64 (pow.f64 (-.f64 m n) (/.f64 1 2)) (pow.f64 (-.f64 m n) (/.f64 1 2)))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 140 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (Rewrite<= fabs-sqr_binary64 (fabs.f64 (*.f64 (pow.f64 (-.f64 m n) (/.f64 1 2)) (pow.f64 (-.f64 m n) (/.f64 1 2))))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (-.f64 (-.f64 (fabs.f64 (Rewrite<= sqr-pow_binary64 (pow.f64 (-.f64 m n) 1))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 140 points decrease in error
      (-.f64 (-.f64 (fabs.f64 (Rewrite=> unpow1_binary64 (-.f64 m n))) l) (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate--r+_binary64 (-.f64 (fabs.f64 (-.f64 m n)) (+.f64 l (pow.f64 (-.f64 (*.f64 1/2 m) M) 2)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (fabs.f64 (-.f64 m n)) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (-.f64 (*.f64 1/2 m) M) 2) l))): 0 points increase in error, 0 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification2.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -5 \cdot 10^{+165}:\\ \;\;\;\;\cos M \cdot e^{\ell}\\ \mathbf{elif}\;\ell \leq -2 \cdot 10^{-51}:\\ \;\;\;\;\cos M \cdot e^{\left(m - \left(n + \ell\right)\right) - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{\left(m - \left(n + \ell\right)\right) - {\left(m \cdot 0.5 - M\right)}^{2}}\\ \end{array} \]

Alternatives

Alternative 1
Error1.4
Cost26624
\[\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
Alternative 2
Error2.0
Cost13636
\[\begin{array}{l} \mathbf{if}\;\ell \leq -5.2 \cdot 10^{+163}:\\ \;\;\;\;\cos M \cdot e^{\ell}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{\left(m - \left(n + \ell\right)\right) - M \cdot M}\\ \end{array} \]
Alternative 3
Error13.3
Cost13388
\[\begin{array}{l} t_0 := e^{M \cdot \left(-M\right)}\\ t_1 := e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{if}\;M \leq -215000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq -9.8 \cdot 10^{-297}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq 2.15 \cdot 10^{-185}:\\ \;\;\;\;\frac{\cos M}{e^{\ell}}\\ \mathbf{elif}\;M \leq 2.55 \cdot 10^{-8}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error9.7
Cost13380
\[\begin{array}{l} \mathbf{if}\;n \leq 1.65 \cdot 10^{-201}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;n \leq 720:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-n}\\ \end{array} \]
Alternative 5
Error9.7
Cost13320
\[\begin{array}{l} \mathbf{if}\;n \leq 10^{-205}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;n \leq 720:\\ \;\;\;\;e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-n}\\ \end{array} \]
Alternative 6
Error11.7
Cost6984
\[\begin{array}{l} t_0 := e^{M \cdot \left(-M\right)}\\ \mathbf{if}\;M \leq -215000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq 2.55 \cdot 10^{-8}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error27.5
Cost6656
\[e^{M \cdot \left(-M\right)} \]
Alternative 8
Error59.4
Cost6464
\[\cos M \]
Alternative 9
Error59.4
Cost64
\[1 \]

Error

Reproduce

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