In shm F= -m

^2x = - kx
k = elastic const. i.e when displ is towards right when force points towards left.This sort of a force acts when an elastic body such as a spring is deformed.Now F = - dU/dx
or dU/dx= kx, now on integrating within limits of 0 to U, we get U = 1/2 kx^2 = negative of work done by this force.
total mechanical energy is a const qty and since the force is conservative ,
E = 1/2 k A^2.Pot energy in any kind of osscilation,increeases at the expense of K.E. while moving away from the mean position.
Now when we come to waves,
let the eqn of a wave be y = f(ax+- bt) , speed of the wave is dy/dt x is considerd to be const.
Now pot energy here is the amt of work done in stretching the string and it depends on the tension and the slope .
So pot energy per unit vol = 1/2 (wave speed)^2 * (dy/dx)^2*mass ,it can be concluded that
for a mass attached to a spring and osscilating simple harmonic wave the results come out to be the same