At the point of maximum displacement (a), the elastic potential energy of the spring is maximum:
[tex]U_i= \frac{1}{2} ka^2 [/tex]
while the kinetic energy is zero, because at the maximum displacement the mass is stationary, so its velocity is zero:
[tex]K_i =0[/tex]
And the total energy of the system is
[tex]E_i = U_i+K= \frac{1}{2}ka^2 [/tex]
Viceversa, when the mass reaches the equilibrium position, the elastic potential energy is zero because the displacement x is zero:
[tex]U_f = 0[/tex]
while the mass is moving at speed v, and therefore the kinetic energy is
[tex]K_f = \frac{1}{2} mv^2 [/tex]
And the total energy is
[tex]E_f = U_f + K_f = \frac{1}{2} mv^2 [/tex]
For the law of conservation of energy, the total energy must be conserved, therefore [tex]E_i = E_f[/tex]. So we can write
[tex] \frac{1}{2} ka^2 = \frac{1}{2}mv^2 [/tex]
that we can solve to find an expression for v:
[tex]v= \sqrt{ \frac{ka^2}{m} } [/tex]