# Ordinary Differential Equations/Simple Harmonic Motion

Simple Harmonic Motion can be used to describe the motion of a mass at the end of a linear spring without a damping force or any other outside forces acting on the mass. It's best thought of as the motion of a vibrating spring.

## Laws of Motion

There are generally two laws that help describe the motion of a mass at the end of the spring.

1. Hooke's Law
2. Newton's Second Law

### Hooke’s Law

To demonstrate Hooke’s Law, we will use a (massless) spring hung from a ceiling. The ceiling is rigid, and offers no effect on the spring’s motion.

If we leave the spring alone, and don’t attach a mass, the spring will remain in an un-stretched state with a total length ${\displaystyle l}$. Now, if we attach an arbitrary mass (${\displaystyle m_{1}>0}$) to the free end of the spring, then the spring will stretch a distance (${\displaystyle s}$) from the original length (${\displaystyle l}$). So now ${\displaystyle {\mbox{length}}_{\mbox{total}}=s+l}$.

Eventually, the mass will come to rest at this new total length at a position known as the Equilibrium Position. This position is what many of the calculation reference as ${\displaystyle x=0}$.

Here is where Hooke's law comes into play. As the spring stretches, when the mass is attached, a force is exerted on the mass in the direction of the original un-stretched position. This force is expressed using the equation: ${\displaystyle {\vec {F}}={\vec {k}}s}$. Where ${\displaystyle {\vec {F}}}$ is the force exerted on the mass by the spring, ${\displaystyle {\vec {k}}}$ is the spring's Constant of Proportionality, often called the spring constant, and ${\displaystyle s}$ is the distance the spring stretched from its un-stretched position.

Suppose that any movement by the mass in a downward direction is considered positive and upward is negative. If you take the weight (${\displaystyle {\vec {W}}}$) of the mass, it will be equal to the force exerted by the spring when ${\displaystyle x=0}$, or the equilibrium position. Due to this, we now know that ${\displaystyle {\vec {W}}={\vec {F}}}$. Since ${\displaystyle {\vec {W}}=m{\vec {g}}}$ and ${\displaystyle {\vec {F}}={\vec {k}}s}$, by substitution, we get ${\displaystyle m{\vec {g}}={\vec {k}}s}$. If you set these equal to zero, you'll get ${\displaystyle m{\vec {g}}-{\vec {k}}s=0}$.

Why is ${\displaystyle {\vec {k}}s}$ negative? This is because no matter what the mass does, the spring-with-gravity combination will always exert a force opposite to its motion. For example, as the mass travels downward beyond the equilibrium point, the spring will pull it back upwards in an attempt to regain equilibrium. When the mass gets above the equilibrium point, the spring contribution is less and the net acceleration is then downward toward regaining equilibrium. It behaves the same as if in an idealized example imagined all far removed from any local gravity effect, and that the spring is alternately stretched and compressed about a completely unstressed state. Some examples invent a horizontal version with the mass sliding over a frictionless surface, the better to then introduce a friction component.

#### Examples

##### Example 1

A mass of ${\displaystyle 1/4{\mbox{ slug}}}$ is attached to a spring and stretches it ${\displaystyle 6{\mbox{ inches}}}$. Calculate the spring's constant of proportionality.

Solution
Using the combined equation ${\displaystyle mg-ks=0}$, we know ${\displaystyle m=1/4{\mbox{ slug}}}$ and ${\displaystyle s=6{\mbox{ inches}}=1/2{\mbox{ ft}}}$

(we omit the vector since we're only looking for a magnitude)

By definition, we know ${\displaystyle g=32ft/s^{2}}$

Plugging everything in, we get ${\displaystyle (1/4slug)(32ft/s^{2})-k(1/2ft)=0}$.

Solving for ${\displaystyle k}$, we find
${\displaystyle 8{\mbox{ lb}}=k(1/2{\mbox{ ft}})}$
${\displaystyle 16{\mbox{ lb}}/{\mbox{ft}}=k}$

##### Example 2

An object of unknown mass stretches a spring 10 cm from the ceiling. The spring's orignal length was 7 cm. Calculate the weight of the object if the spring constant is 5 N/m.

Solution
First, we need the distance the spring is stretched after the mass is attached. This can be found using ${\displaystyle {\mbox{length}}_{\mbox{total}}=s+l}$, where ${\displaystyle {\mbox{length}}_{\mbox{total}}=10{\mbox{ cm}}=.1{\mbox{ m}}}$ and ${\displaystyle l=7{\mbox{ cm}}=.07{\mbox{ m}}}$. Plugging everything in and solving for ${\displaystyle s}$ we find ${\displaystyle s=.03{\mbox{ m}}}$.

By definition we know ${\displaystyle W=mg}$. With that, and ${\displaystyle mg-ks=0}$, we plug everything in and solve for ${\displaystyle W}$.

${\displaystyle W-(5{\mbox{ N}}/{\mbox{m}})(.03{\mbox{ m}})=0}$
${\displaystyle W=.15{\mbox{ N}}=150{\mbox{ g}}}$

### Newton’s Second Law of Motion

Now, imagine that we have another mass hanging from a spring, which is attached to the ceiling. This mass is then pulled down a distance ${\displaystyle x}$, below the equilibrium point, and released. By Hooke's Law, the spring will be pulled back up, and after reaching it's highest point, start to travel back down.

If the mass continues this motion, without any outside influence, it's known as Free Motion. During this motion, there is acceleration acting on the mass to keep it in motion. This acceleration can be readily found in Newton's Second Law of Motion using ${\displaystyle {\vec {F}}=m{\vec {a}}}$. Where ${\displaystyle {\vec {F}}}$ is the force of the spring acting on the mass ${\displaystyle m}$ and ${\displaystyle {\vec {a}}}$ is the acceleration of that mass due to the force acting on it.

From Calculus, we know that ${\displaystyle a={\frac {d^{2}x}{dt^{2}}}}$ or ${\displaystyle a={\ddot {x}}}$. If we substitute this into our equation from the section on Hooke's Law, we find ${\displaystyle m{\ddot {x}}-k(s+x)=0}$. However, since this motion is always in the direction of the spring's force, our equation becomes ${\displaystyle m{\ddot {x}}+k(s+x)=mg}$. Expanding this, and solving for ${\displaystyle m{\ddot {x}}}$ we get ${\displaystyle m{\ddot {x}}=-k(s+x)+mg=-ks-kx+mg}$. Knowing that ${\displaystyle mg-ks=0}$, we can simplify our equation to end with ${\displaystyle m{\ddot {x}}=-kx}$.

## The Differential Equation of Free Motion

Finally, if we set the equation above equal to zero, we end up with the following:

${\displaystyle m{\ddot {x}}+kx=0}$

Since our leading coeffiecient should be equal to 1, we divide by the mass to get:

${\displaystyle {\ddot {x}}+{\frac {k}{m}}x=0}$

If we set ${\displaystyle \omega ^{2}={\frac {k}{m}}}$, we'll have our final form of this equation:

${\displaystyle {\ddot {x}}+\omega ^{2}x=0}$

The above equation is known to describe Simple Harmonic Motion or Free Motion.

### Initial Conditions

With the free motion equation, there are generally two bits of information one must have to appropriately describe the mass's motion.

1. The starting position of the mass. ${\displaystyle x_{2}}$
2. The starting direction and magnitude of motion. ${\displaystyle v}$

Generally, one isn't present without the other. For simplicity, we will consider all displacement below the equilibrium point as ${\displaystyle x>0}$ and above as ${\displaystyle x<0}$.

For upward motion ${\displaystyle v<0}$, and for downward motion ${\displaystyle v>0}$.

### Solution

Multiplying this equation by ${\displaystyle {\dot {x}}}$ gives:

${\displaystyle m{\ddot {x}}{\dot {x}}+kx{\dot {x}}=0}$

The first and the second addends are exact derivatives, so this equation may be integrated to obtain the following relation:

${\displaystyle m{\frac {{\dot {x}}^{2}}{2}}+k{\frac {x^{2}}{2}}=E}$

The first addend of this relation is known as the kinetic energy of the mass and the second — as the potential energy of the spring. The above integral represents the energy conservation law. This is also a first order separable differential equation. It may be rewritten as

${\displaystyle {\frac {dx}{\sqrt {{\frac {2E}{m}}-{\frac {k}{m}}x^{2}}}}=\pm dt}$

The integration of this relation gives

${\displaystyle \arccos x{\sqrt {\frac {k}{2E}}}=\pm {\sqrt {\frac {k}{m}}}t+\varphi }$

Or, finally rearranging the result, substituting ${\displaystyle \omega ={\sqrt {k/m}}}$, and solving for ${\displaystyle x}$ we obtain

${\displaystyle x={\sqrt {\frac {2E}{k}}}\cos(\omega t+\varphi )}$