def Elastic(m1, m2, v1, v2):
    """Returns a tuple of the velocities resulting from a perfectly
    elastic collision between masses m1 traveling at v1 and m2
    traveling at v2.  This simultaneously conserves momentum and energy."""
    vp2 =  ((m2 * v2) + (m1 * ((2.0 * v1) - v2))) / (m1 + m2)
    vp1 = vp2 + v2 - v1
    return vp1, vp2