Problems for
Intermediate Methods in Theoretical Physics

Edward F. Redish

Stepping the oscillator

Consider a simple harmonic oscillator (e.g., an idealized cart connected to a massless spring as shown in the figure at the right). In this problem, you will solve the equation of motion numerically as weel as analytically and explore the accuracy of your results. Assume the cart has a mass m and the spring has a spring constant k. For this problem, do not convert to dimensionless quantities.
  1. Write Newton's second law for the cart on the spring as a pair of coupled ordinary differential equations for the cart's position (x) and the cart's velocity (v).

  2. Find the particular analytic solution to these equations for the initial conditions

    x(t = 0) = x0
    v(t = 0) = v0

  3. Create a spreadsheet to solve Newton's second law as a stepping law using Euler's method. Set it up so you have columns for t, x, v, and for KE, PE, and Total Energy. Set it up so the calculation uses the following parameters. (It's best to put the parameters somewhere in the spreadsheet and give them a name so that it is easy to vary them later.) Create two graphs, one plotting position and velocity, the other plotting potential, kinetic, and total energies. Be sure to take enough points to do two full oscillations.
  4. Copy your sheet onto a second page and solve the equation with the half-step method. (You will need to insert columns for the 1/2-x and 1/2-v values.
  5. Evaluate your numerical results, comparing them to the exact and to each other.

This page prepared by

Edward F. Redish
Department of Physics
University of Maryland
College Park, MD 20742
Phone: (301) 405-6120
Email: redish@umd.edu

Last revision 14. September, 2004.