Added the definitions of the potential function, along with the invariants we must maintain.