A harmonic oscillator is a system in physics that acts according to Hooke's law. This rule describes elastic behavior, and puts forth that the amount of force applied to a spring, or other elastic object, is proportional to its displacement. A harmonic oscillator system returns to its original position when the force is removed from the elastic object.

In physics courses, a simple example of a block attached to a wall by a spring is often used to illustrate the concept of harmonic oscillation. The surface that the block slides on is assumed to be frictionless. When the system is set into motion, it follows the equation ω_{0} = 2πf_{0}, which is also equal to the square root of the spring constant (k), divided by the mass of the block (m).

ω_{0} is the angular speed, which has units of radians per second, and f_{0} is the natural frequency, which has units of Hertz. The period of the block — the time it takes to go through one complete cycle of motion — is equal to one divided by f_{0}. The spring constant indicates how stiff the spring is, and is unique to each spring. It has units of force per length, for example, Newtons per meter.

This simple example is called an undamped harmonic oscillator, and, theorizes that since the block moves along a frictionless surface, it will continue moving at the same frequency forever. In actuality, however, such a situation would not occur. Real systems with friction are called damped systems, in which the motion of the block will slow down, the displacement of the spring will become shorter, and the system will eventually stop moving.

A harmonic oscillator system may be overdamped, underdamped, or critically damped. Differential equations describe the motion of damped systems, so their solution can be quite complex. Each type of damped system has its own type of motion, however, which is easily recognizable.

In an overdamped system, the block does not oscillate. It returns to its original position slowly after the force is applied and the spring stops moving. The block may oscillate for quite a while in an underdamped system, with the spring lengthening less with each consecutive oscillation until the system returns to rest. A critically damped system behaves in much the same way as an overdamped system, but it is optimally designed to return to the original position as quickly as possible.

A quantum harmonic oscillator describes how two molecules interact with one another. They vibrate back and forth in a similar manner to a mass on a spring. Instead of a spring constant, the equation for a quantum harmonic oscillator uses a bond force constant, which describes the strength of the bond between the two molecules. The relationship between the angular speed and the frequency is the same.