Average Error: 16.2 → 1.3
Time: 14.4s
Precision: binary64
Cost: 20744
\[ \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} \mathbf{if}\;m \leq -2 \cdot 10^{+37}:\\ \;\;\;\;{\left(e^{m \cdot m}\right)}^{-0.25}\\ \mathbf{elif}\;m \leq 5.3 \cdot 10^{-42}:\\ \;\;\;\;\cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot e^{\left(m - \left(n + \ell\right)\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\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)))))))
(FPCore (K m n M l)
 :precision binary64
 (if (<= m -2e+37)
   (pow (exp (* m m)) -0.25)
   (if (<= m 5.3e-42)
     (*
      (cos (* 0.5 (* m K)))
      (exp (- (- m (+ n l)) (pow (- (* (+ m n) 0.5) M) 2.0))))
     (* (cos M) (exp (* -0.25 (* n 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)))));
}
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -2e+37) {
		tmp = pow(exp((m * m)), -0.25);
	} else if (m <= 5.3e-42) {
		tmp = cos((0.5 * (m * K))) * exp(((m - (n + l)) - pow((((m + n) * 0.5) - M), 2.0)));
	} else {
		tmp = cos(M) * 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
    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) :: tmp
    if (m <= (-2d+37)) then
        tmp = exp((m * m)) ** (-0.25d0)
    else if (m <= 5.3d-42) then
        tmp = cos((0.5d0 * (m * k))) * exp(((m - (n + l)) - ((((m + n) * 0.5d0) - m_1) ** 2.0d0)))
    else
        tmp = cos(m_1) * 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) {
	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 tmp;
	if (m <= -2e+37) {
		tmp = Math.pow(Math.exp((m * m)), -0.25);
	} else if (m <= 5.3e-42) {
		tmp = Math.cos((0.5 * (m * K))) * Math.exp(((m - (n + l)) - Math.pow((((m + n) * 0.5) - M), 2.0)));
	} else {
		tmp = Math.cos(M) * Math.exp((-0.25 * (n * n)));
	}
	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):
	tmp = 0
	if m <= -2e+37:
		tmp = math.pow(math.exp((m * m)), -0.25)
	elif m <= 5.3e-42:
		tmp = math.cos((0.5 * (m * K))) * math.exp(((m - (n + l)) - math.pow((((m + n) * 0.5) - M), 2.0)))
	else:
		tmp = math.cos(M) * math.exp((-0.25 * (n * n)))
	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)
	tmp = 0.0
	if (m <= -2e+37)
		tmp = exp(Float64(m * m)) ^ -0.25;
	elseif (m <= 5.3e-42)
		tmp = Float64(cos(Float64(0.5 * Float64(m * K))) * exp(Float64(Float64(m - Float64(n + l)) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0))));
	else
		tmp = Float64(cos(M) * exp(Float64(-0.25 * Float64(n * n))));
	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)
	tmp = 0.0;
	if (m <= -2e+37)
		tmp = exp((m * m)) ^ -0.25;
	elseif (m <= 5.3e-42)
		tmp = cos((0.5 * (m * K))) * exp(((m - (n + l)) - ((((m + n) * 0.5) - M) ^ 2.0)));
	else
		tmp = cos(M) * exp((-0.25 * (n * n)));
	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_] := If[LessEqual[m, -2e+37], N[Power[N[Exp[N[(m * m), $MachinePrecision]], $MachinePrecision], -0.25], $MachinePrecision], If[LessEqual[m, 5.3e-42], N[(N[Cos[N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[(n * n), $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}
\mathbf{if}\;m \leq -2 \cdot 10^{+37}:\\
\;\;\;\;{\left(e^{m \cdot m}\right)}^{-0.25}\\

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

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


\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 m < -1.99999999999999991e37

    1. Initial program 21.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. Simplified21.2

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

      [Start]21.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)} \]

      *-commutative [=>]21.3

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

      associate-*r/ [<=]21.2

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

      associate--r- [=>]21.2

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

      +-commutative [=>]21.2

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

      sub-neg [=>]21.2

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

      distribute-neg-out [=>]21.2

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

      sub-neg [<=]21.2

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

      +-commutative [=>]21.2

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

      associate--l- [<=]21.2

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

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

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

      [Start]0

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

      cos-neg [=>]0

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

      \[\leadsto \cos M \cdot e^{\color{blue}{-0.25 \cdot {m}^{2}}} \]
    6. Simplified0

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

      [Start]0

      \[ \cos M \cdot e^{-0.25 \cdot {m}^{2}} \]

      *-commutative [=>]0

      \[ \cos M \cdot e^{\color{blue}{{m}^{2} \cdot -0.25}} \]

      unpow2 [=>]0

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

      \[\leadsto \color{blue}{e^{-0.25 \cdot {m}^{2}}} \]
    8. Simplified0

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

      [Start]0

      \[ e^{-0.25 \cdot {m}^{2}} \]

      *-commutative [=>]0

      \[ e^{\color{blue}{{m}^{2} \cdot -0.25}} \]

      exp-prod [=>]0

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

      unpow2 [=>]0

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

    if -1.99999999999999991e37 < m < 5.3e-42

    1. Initial program 11.1

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

      [Start]11.1

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

      *-commutative [=>]11.1

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

      associate-*r/ [<=]11.1

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

      associate--r- [=>]11.1

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

      +-commutative [=>]11.1

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

      sub-neg [=>]11.1

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

      distribute-neg-out [=>]11.1

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

      sub-neg [<=]11.1

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

      +-commutative [=>]11.1

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

      associate--l- [<=]11.1

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

      \[\leadsto \cos \color{blue}{\left(0.5 \cdot \left(K \cdot m\right)\right)} \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
    4. Applied egg-rr2.6

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

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

      [Start]2.6

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

      sub-neg [<=]2.6

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

      associate-+r- [=>]2.6

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

      sub-neg [<=]2.6

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

      associate--l- [=>]2.6

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

      fma-neg [<=]2.6

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

      *-commutative [=>]2.6

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

      +-commutative [<=]2.6

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

    if 5.3e-42 < m

    1. Initial program 22.1

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

      [Start]22.1

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

      *-commutative [=>]22.1

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

      associate-*r/ [<=]22.1

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

      associate--r- [=>]22.1

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

      +-commutative [=>]22.1

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

      sub-neg [=>]22.1

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

      distribute-neg-out [=>]22.1

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

      sub-neg [<=]22.1

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

      +-commutative [=>]22.1

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

      associate--l- [<=]22.1

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

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

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

      [Start]22.5

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

      *-commutative [=>]22.5

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

      unpow2 [=>]22.5

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

      \[\leadsto \color{blue}{e^{-0.25 \cdot {n}^{2}} \cdot \cos \left(-M\right)} \]
    6. Simplified0.4

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

      [Start]0.4

      \[ e^{-0.25 \cdot {n}^{2}} \cdot \cos \left(-M\right) \]

      unpow2 [=>]0.4

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

      cos-neg [=>]0.4

      \[ e^{-0.25 \cdot \left(n \cdot n\right)} \cdot \color{blue}{\cos M} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.3

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

Alternatives

Alternative 1
Error1.2
Cost26624
\[\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
Alternative 2
Error2.2
Cost13380
\[\begin{array}{l} \mathbf{if}\;n \leq 54:\\ \;\;\;\;e^{\left(m - \left(n + \ell\right)\right) - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
Alternative 3
Error3.6
Cost6976
\[e^{\left(m - \left(n + \ell\right)\right) - M \cdot M} \]
Alternative 4
Error42.9
Cost6528
\[e^{-\ell} \]
Alternative 5
Error59.4
Cost6464
\[\cos M \]
Alternative 6
Error59.4
Cost64
\[1 \]

Error

Reproduce

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