The kinetic energy and potential energy of particle (executing S.H.M) at any instant is given by
K.E. = 1/2 Mω2(r2 - x2)
and P.E. = 1/2 Mω2x2
When particle is at mean position. i.e., x = 0
K.E. = 1/2 Mω2r2 (maximum)
and P.E. = 0
Thus, at mean position, the whole of energy of the particle is kinetic energy.
As the displacement of the particle increase (i.e., x increase), the kinetic energy of the particle goes on decreasing while potential energy goes on increasing. This means kinetic energy is being converted onto potential energy. When the particle reaches the extreme position, where displacement is maximum and velocity is zero.
then,
K.E. = 1/2 Mω2 (r2 - r2) = 0
P.E. = 1/2 Mω2r2 (maximum)
The variation of kinetic energy and potential energy with displacement is shown in Figure.

The total energy (E) is represented by a straight line parallel to displacement axis. This shows that the total energy (E) of the particle at any instant remains constant.