Average Error: 14.9 → 1.2
Time: 8.5s
Precision: binary64
\[[m, n] = \mathsf{sort}([m, n]) \\]
\[\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)} \]
\[\cos M \cdot \frac{e^{m - n}}{e^{\ell + {\left(\frac{m + n}{2} - M\right)}^{2}}} \]
(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
 (* (cos M) (/ (exp (- m n)) (exp (+ l (pow (- (/ (+ m n) 2.0) 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) {
	return cos(M) * (exp((m - n)) / exp((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((((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
    code = cos(m_1) * (exp((m - n)) / exp((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((((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) {
	return Math.cos(M) * (Math.exp((m - n)) / Math.exp((l + Math.pow((((m + n) / 2.0) - M), 2.0))));
}
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):
	return math.cos(M) * (math.exp((m - n)) / math.exp((l + math.pow((((m + n) / 2.0) - M), 2.0))))
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)
	return Float64(cos(M) * Float64(exp(Float64(m - n)) / exp(Float64(l + (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))))
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 = code(K, m, n, M, l)
	tmp = cos(M) * (exp((m - n)) / exp((l + ((((m + n) / 2.0) - M) ^ 2.0))));
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_] := N[(N[Cos[M], $MachinePrecision] * N[(N[Exp[N[(m - n), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(l + N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $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)}
\cos M \cdot \frac{e^{m - n}}{e^{\ell + {\left(\frac{m + n}{2} - M\right)}^{2}}}

Error

Bits error versus K

Bits error versus m

Bits error versus n

Bits error versus M

Bits error versus l

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 14.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. Simplified14.9

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

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

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

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

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

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

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

Reproduce

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