Convergence analysis of the formal energies of symplectic methods for Hamiltonian systems