Average Error: 15.6 → 1.3
Time: 11.1s
Precision: binary64
Cost: 20672
\[\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 e^{\left|m - n\right| - \left(\ell + \left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right)\right)}\]
\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 e^{\left|m - n\right| - \left(\ell + \left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right)\right)}
(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
   (- (fabs (- m n)) (+ l (* (- (/ (+ m n) 2.0) M) (- (/ (+ m n) 2.0) M)))))))
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(fabs(m - n) - (l + ((((m + n) / 2.0) - M) * (((m + n) / 2.0) - M))));
}

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

Alternatives

Alternative 1
Error5.2
Cost14786
\[\begin{array}{l} \mathbf{if}\;\ell \leq -3.0224362588245987 \cdot 10^{-172}:\\ \;\;\;\;0\\ \mathbf{elif}\;\ell \leq 3.8610656095079626 \cdot 10^{-162}:\\ \;\;\;\;e^{\left|m - n\right| - \left(\left(n \cdot n\right) \cdot 0.25 + \left(\ell + m \cdot \left(n \cdot 0.5 + m \cdot 0.25\right)\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 2
Error4.2
Cost64
\[0\]
Alternative 3
Error59.4
Cost64
\[1\]

Error

Derivation

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

    \[\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 around 0 1.3

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

    \[\leadsto \color{blue}{\cos M} \cdot e^{\left|m - n\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt_binary64_78232.2

    \[\leadsto \cos M \cdot e^{\left|m - n\right| - \left({\color{blue}{\left(\sqrt{\frac{m + n}{2} - M} \cdot \sqrt{\frac{m + n}{2} - M}\right)}}^{2} + \ell\right)}\]
  7. Applied unpow-prod-down_binary64_83932.2

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

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

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

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

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

Reproduce

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