A Computational Method for the Stability of a Class of Mechanical Systems