A particle executing simple harmonic motion possesses both the potential energy and kinetic energy. The potential energy is due to the displacement of the particle from mean position and the kinetic energy is due to the motion of the particle. At the mean position, the displacement is zero and hence the potential energy of the particle at the mean position is also zero. On the other hand, at mean position, velocity is maximum and hence the kinetic energy of particle is maximum at this position. At extreme position, potential energy is maximum because of maximum displacement and kinetic energy is zero due to zero velocity of the particle. At the intermediate positions, the energy of the particle is the sum of kinetic energy and potential energy.
i.e., Energy, E = P.E. + K.E. ...(i)
Potential Energy:- Consider a particle of mass M executing S.H.M. Let the particle is displaced through a distance x from mean position O to position P (See fig).

The acceleration of the particle at P is a = -ω2x and is directed towards mean position. Therefore, the restoring force acting on the particle is
F = Ma = Mω2x
Let the particle is displaced through a distance dx to the Q, therefore, work done on the particle is
dW = vector(F.dx)
= F dx cos 180° (∴ θ = 180°)
= -F dx
Putting the value of F, we get
dW = M ω2x dx ...(ii)
Total work done to displace the particle from mean position to point P, where displacement = x can be calculated by integrating eq. (ii)

This work done is stored as the potential energy of the particle.
Thus the potential energy of the particle is
P.E. = W = 1/2 Mω2x2 ....(iii)
Kinetic energy:- The kinetic energy of the particle executing S.H.M. at any instant is given by
K.E. = 1/2 Mv2
But, velocity of a particle executing S.H.M. is given v = ω√{r2 - x2}
where r is the amplitude of the particle.
Hence, K.E. = 1/2 Mω2 (r2 - x2) ....(iv)
Substituting the values of eqn. (iii) and (iv) in eqn. (i) we get
E = 1/2 Mω2x2 + 1/2 Mω2(r2 - x2)
or, E = 1/2 Mω2r2 ...(v)
Since ω = 2πv
We have, E = 1/2 M x 4π2v2r2
or, E = 2π2 Mv2r2 ....(vi)
Thus, energy of the particle executing S.H.M. is directly proportional to
(i) square of the amplitude (r) of the particle and (ii) square of the frequency (v) of the vibrating particle.