The M 2 variables are devised to extend M T 2 by promoting transverse masses to Lorentzinvariant ones and making explicit use of on-shell mass relations. Unlike simple kinematic variables such as the invariant mass of visible particles, where the variable definitions directly provide how to calculate them, the calculation of the M 2 variables is undertaken by employing numerical algorithms. Essentially, the calculation of M 2 corresponds to solving a constrained minimization problem in mathematical optimization, and various numerical methods exist for the task. We find that the sequential quadratic programming method performs very well for the calculation of M 2 , and its numerical performance is even better than the method implemented in the existing software package for M 2 . As a consequence of our study, we have developed and released yet another software library, YAM2, for calculating the M 2 variables using several numerical algorithms.