Energy conversion during the vibrations of the mathematical pendulum and the weight on the spring