Explore BrainMass

Simple Harmonic Motion: Write a program to integrate an equation

See the attached file for the formulas.

Determine an appropriate step size h by assuming that an h that works as expected for simple harmonic motion is good enough for the given initial angle. In particular, if the position at the end of one period is within 0.1% of the original point, we'll be satisfied.


Solution Preview

See attached file.

I chose to solve this using Euler's method. First you have to convert the second-order ODE into two first-order ODEs.

Let v = theta'

Since theta'' = v', v' = -(g/l)*theta.

With me this far? Please try to make the above make sense to you. All we are doing is breaking the problem up into two smaller problems.

Now we have to iterate with the following (where i denotes the discrete time interval):

theta[i+1] = ...

Solution Summary

The solution provides good explanations and alternative methods used in solving the problems.