how energy is conserved in a pendulum