Physics 307 Homework 4
Due Thursday, 11 October, by 5 PM
Note: See the notes on symplectic integrators for summaries of the different solvers used in this project.
Now we will graduate to second-order differential equations, and solve a DE that we can’t do with pen and paper. The equation of motion for a pendulum is
∂2θ g
∂t2 = −L sin θ (1)
In mechanics class you solved this by taking the small-angle approximation sin θ θ; the equation then has a solution
where ω = . g
θ(t) = A sin(ωt + φ) (2)
giving a period T = 2π. L . This is valid only in the limit θ → 0
This equation is very difficult to solve without making this approximation using pen and paper, but you have a computer!
In this project, you will create and animate a computer simulation of a swinging pendulum, and study how its swing period depends on the angle at which it is swinging. In order to do this, you will need to be able to distinguish small effects caused by physics (a small shift in the period of your simulation caused by the change in amplitude) from small effects caused by numerical artifacts (a small shift in the period of your simulation caused by the fact that numerical solutions are always approximations). The first one is what we are interested in studying; the second one is just a distraction.
Nota bene: While I’ve asked you to do a few other things, the primary purpose of this project is the last question – to examine the nonlinearities in a swinging pendulum. Your report should focus on this. The overarching question is: How does the period of a swinging pendulum depend on its amplitude, and how can computer simulations answer this question in a way that pen-and-paper calculations cannot?
1. Without making the small-angle approximation, write a computer program that solves Newton’s law (rotational form) to compute the oscillation of a swinging pendulum using the Euler-Cromer algorithm, which is a first-order symplectic integrator. (It is perhaps the easiest to code of all of them.)
2. Animate your pendulum using anim.
3. Use your program to make graphs of θ(t) and ω(t) as a function of time for a few periods, and plot them on top of each other. Do your data make sense? As a note, familiarize yourself with the ! bypass feature of anim, which will make it easy for you to get both animation and graphical output at the same time.
4. Modify your program to determine the period of the pendulum and print it out. You can determine when a period has elapsed by looking for sign changes in ω; look at the graphs you made in the last step for a reminder of how to do this.
5. Does your program give you the result you expect (i.e. T ≈ 2π. L ) in the limit where
the initial amplitude is small?
6. Suppose a pendulum clock keeps accurate time when θmax = 5◦. How many seconds will it gain or lose per day if it is swinging at an angle of θmax = 20◦?
7. Modify your program to use the leapfrog algorithm, which is a second-order symplectic integrator that you will use for the rest of the semester. (This should be an easy, fast modification.) Note that if you want the added precision from the use of a second-order solver, you should use the second-order interpolation mechanism for ω that you worked out in Project 2.
8. Make a plot of the fractional deviation in the period, defined as ∆ = τ−τ0 . Here τ0 is the small-angle-limiting period, τ0 = 2π L. Calculate this for a range of θmax from 10−5 to 2 (radians). Make a log-log plot of ∆ vs. θmax. Your plot should cover amplitudes
from around 10−6 to 2 radians. Here you might see deviations from the small-angle
period from two sources: actual physical effects, and error in your numerical solution. You should take whatever steps you can to minimize the latter (using a reasonable stepsize, using interpolation to determine the period as you did in HW3, etc.), and then correctly interpret your data in light of the fact that you may still have errors related to your numerical solution.
Based on what you know about the power series expansion of sin(x), comment on its appearance. Is it what you expect?