Consider a spring of spring constant k connected to a mass m as shown. When the mass is displaced from its equilibrium position by some speed, it will oscillate to the right and left.

At the beginning x=0, t = 0, the energy of the system will consist totally of the mass spring’s kinetic energy (KE).

From 0 < t < T/4, as the mass moves away from x = 0, the spring pulls the mass towards equilibrium position, this KE is converting to PE as stored spring potential energy.

At the maximum amplitude, x = x

From T/4 < t < T/2 as the mass moves towards x = 0, the spring pulls the mass toward the equilibrium position, the potential energy is transformed back into kinetic energy (KE) until at the equilibrium position the kinetic energy will reach a maximum.

similarly, from T/2 < t < 3T/4, the similar energy conversion occurs but now for negative values of x moving away from equilibrium position .

similarly, from 3T/4 < t < T, the similar energy conversion occurs but now for negative values of x moving towards equilibrium position .

The constant exchange between potential energy PE and kinetic energy KE is essential in maintaining oscillations. The total energy TE, which is the summation of kinetic and potential energy, will always add up to a constant value as shown.

this is how the x vs x looks together of the energy vs x graphs

recalling Energy formula

KE = ½ m v

PE = ½ k x

TE = KE + PE = ½ m v

since $v$

KE = ½ m v

from the simple harmonic motion, we also can get $\omega $

PE = ½ k x

therefore,

TE = KE + PE = ½ m ω

hence or otherwise the table below shows the various formula and their values

general energy formula | SHM energy formula | when x = -x_{0} |
when x = 0 | when x = x_{0} |

KE = ½ m v^{2} |
KE = ½ m ω^{2}( x_{o}^{2}-
x^{2}) |
0 | ½ m ω^{2}x_{0}^{2} |
0 |

PE = ½ k x^{2} |
PE = ½ m ω^{2}x^{2} |
½ m ω^{2}x_{0}^{2} |
0 | ½ m ω^{2}x_{0}^{2} |

TE = KE + PE |
TE = ½ m ω^{2}( x_{o}^{2}-
x^{2}) + ½ m ω^{2}x^{2} |
½ m ω^{2}x_{0}^{2} |
½ m ω^{2}x_{0}^{2} |
½ m ω^{2}x_{0}^{2} |

If no energy is lost during an oscillation, then total energy remains constant.