MyPhysicsLab – Single Spring

Instructions: drag the block with your mouse;   to change a parameter click it, type and hit enter

vertical axis:    horizontal axis:    graph type:


Try using the graph and changing parameters like mass or spring stiffness to answer these questions about the spring simulation:

You'll find the answers below.

To show the graph and parameters, click on the "show graph+controls" button above. You can set what variables are shown on the vertical or horizontal axis by selecting from the pop-up menu above. To change a parameter, click on it, type the new value and hit the enter key.


A spring generates a force proportional to how far it is stretched (and acting in the opposite direction to the stretch)

F = -k*stretch

Assume that the origin is at the connection of the wall and spring. Define the following variables and constants

We assume that k>0.  The stretch of the spring is given by

stretch = x - R

If we adjust our coordinate system so that x = 0 corresponds to the spring being unstretched, then the stretch is simply

stretch = x

So the force equation becomes

F = - k x

Combining this with Newton's law of motion F = m a, and the definition of acceleration as the second derivative of position a = x'' we have the differential equation:

-k x = m x''

or equivalently:

x'' = -(k/m)x

If you set the graph on the simulation to plot acceleration against position, you will get a straight line, with slope = -k/m. So if you increase the stiffness of the spring, the line becomes steeper. If you increase the mass, the line becomes less steep.

Numerical Solution

To solve this equation numerically (ie. by computer) we use the Runge-Kutta method. To do so we need to convert the second order differential equation

x'' = -(k/m)x

into a set of first order differential equations. First we define a new variable, velocity, as v = x'. Then we have a system of two first order differential equations:

x' = v
v' = -(k/m)x

This is the form that we need in order to use the Runge-Kutta method for numerically solving the differential equation.

To begin the simulation, we initialize the two variables x,v for their value at time t=0. Then we use the Runge-Kutta algorithm to calculate the values of x,v after a short time interval, and this continues indefinitely.

Analytic Solution

Assuming that the initial velocity of the block is zero, the analytic solution is given by

x(t) = x0 cos(sqrt(k/m) t)

where x0 = initial position of the block and t = time. The period of the oscillation is the time it takes to repeat. From the solution we see that the oscillation repeats when sqrt(k/m) t = 2π, and so the period is

t = 2π sqrt(m/k)

The frequency is the inverse of the period so,

frequency = (1/2π) sqrt(k/m)

So we predict that

You can check these predictions by modifying the parameters on the simulation (you'll need a stopwatch to time the frequency).

Here is the derivation of the analytic solution.

Puzzle Answers

Question: What is the relationship between acceleration and position?

Answer: It is a linear relationship as given by the equation x'' = -(k/m)x  where x= position, x''= acceleration, m= mass, and k= spring stiffness.

Question: How do mass or spring stiffness affect the relationship between acceleration and position?

Answer: From the equation x'' = -(k/m)x we know that there is a linear relationship between acceleration and gravity. The mass and spring stiffness affect the slope of this line.

Question: How do mass or spring stiffness affect the period or frequency of the oscillation?

Answer: The analytic solution is

x(t) = x0 cos(sqrt(k/m) t)

and the frequency is given by

frequency = (1/2π) sqrt(k/m)

So we predict that