Approximation of an energy function in transient stability analysis of power systems