the potential energy of the spring is increased when you pull it back. PE = 1/2*kx^2. This gets transferred to kinetic energy with the spring flinging forward and when the spring is back to its original position, the potential energy is again 0, but kinetic energy is max. Then when it keeps extending, the potential energy again increases and kinetic decreases and it goes forever.
Latest Answers