Consider a mass on a frictionless horizontal surface. Connect a spring to it and set the system into motion and it will oscillate back and forth. How can we fully describe the motion?
Start with the free-body diagram. The normal force is cancelled by the force of gravity, and the only horizontal force is the spring force. Therefore:
ΣF = ma
-kx = ma
The acceleration is the second derivative of the position with respect to time. This gives:
-kx = m d2x/dt2
d2x/dt2 = -(k/m) x
What function do you know that, when you take its second derivative, you get the negative of the function?
Sounds like a sine or a cosine.
Let's guess at a solution: x(t) = A cos(ωt)
Here A represents the amplitude of the oscillation, and ω is called the angular frequency. Also, a sine works just as well as a cosine.
Taking the second derivative of x(t) gives:
v = dx/dt = -Aω sin(ωt)
a = d2x/dt2 = -Aω2 cos(ωt)
a = -ω2 x
Compare this to the equation we derived for the mass on the spring:
a = -(k/m) x
Our solution works fine as long as ω = (k/m)½
Motion described by an equation like x(t) = A cos(ωt) is known as simple harmonic motion.
Given that a = -ω2 x, any time you find the acceleration to be proportional to the negative of the displacement you'll have a system experiencing simple harmonic motion, with the angular frequency being the square root of whatever is multiplying -x.
All simple harmonic motion systems have these two features:
No loss of mechanical energy.
A restoring force or torque that is proportional to the displacement from equilibrium. The force or torque is also opposite to the displacement - that's what "restoring" implies.
The motion of the system is described by an equation of the form
x(t) = A cos(ωt + δ).
The relationship between the acceleration and the displacement is:
a = -ω2 x
where ω is the angular frequency of the system.
The period of oscillation is T = 2π/ω
If a mass is oscillating vertically at the end of a spring, you might think that we'd need to build in gravitational potential energy to handle the conservation of energy properly. You can do this if you want, measuring the elastic potential energy from the equilibrium length of the spring, but you don't have to.
If you measure the displacements of the spring about the equilibrium position with the mass attached to the spring, this is the point where the spring force cancels the force of gravity. Measured from this point, you just have to consider the kinetic energy and the elastic potential energy - don't worry about gravity.