No energy is lost during SHM. In reality, energy is dissipatedthis is known as damping. Damped harmonic motion arises when energy loss is included.
A natural model for damping is to assume that the resistive force is opposite and proportional to the velocity. Then the equation of motion is:
∑ F =  k x  b v = m a
Writing v and a in terms of time derivatives of the displacement, the equation of motion is:

=  

x   


The solution to this equation is:
x(t) = A e^{bt/2m}
cos(ωt+φ)
where
ω  =  ( 

 

)  ^{½}  ≡  (  ω_{o}^{2}   

)  ^{½} 
There are 4 different behaviors that depend on the damping constant b:
In the underdamped regime, the energy decays exponentially in time:
E(t) = ½ k x^{2}_{max} = ½ k A e^{bt/m} ≡ E_{0} e^{t/τ}
where τ is the time constant of the damping.