def estimateGalaxyMass(pot_ext, r_gal, G):
    """ Estimate the equivalent mass of galaxy by - pot_ext*r_gal/G
    Parameters:
    -------------
    pot_ext: float
       the external potential of the center of the particle system
    r_gal: float
       the distance between the center of the particle system to the galactic center
    G: float
       gravitational constant

    Return:
    -------------
    M_galaxy: float
       the estimated mass of the galaxy
    """
    M_galaxy = - pot_ext*r_gal/G
    if (M_galaxy<0):
        raise ValueError('External potential is positive! ', pot_ext)
    return M_galaxy