

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Write a program to perform a numerical integration of the trajectory of a particle moving in one dimension. The particle’s position and velocity are updated at each time step according to the rules
ti+1 = ti + δt xi+1 = xi + vi δt + 12 ai δt^2 vi+1 = vi + ai δt
where the acceleration ai = a(xi, vi, ti) is recomputed at the start of each step, allowing the possi- bility of arbitrarily complex motion.
xi = x 0 + v 0 ti + 12 a t^2 i vi = v 0 + a ti
for fixed a, show that the rule applied to (xi, vi, ti) gives
xi+1 = x 0 + v 0 ti+1 + 12 a t^2 i+ vi+1 = v 0 + a ti+
Now use your program to answer the following questions.
with k = 4, corresponding to simple harmonic motion with natural frequency ω 0 = 2. (a) With initial conditions x 0 = 0, v 0 = 1 at time t = 0, follow the particle’s motion with time step δt = 0.05. Plot the particle’s trajectory (x versus t) for 0 ≤ t ≤ 4 π. (b) What is the exact (analytical) solution to this motion? (c) Is the “amplitude” of the numerically determined motion (i.e. the absolute value of x at each successive maximum or minimum) constant, as expected? If not, by what factor does the amplitude change from peak to peak for δt = 0.05. Try decreasing δt until the amplitude remains constant to within 1 percent from one cycle to the next. (You can estimate the amplitude “by eye” from a graph or modify your program to determine it more accurately by looking for instants when v = 0.) What is the value of δt thus obtained?
(d) Write down an expression for the instantaneous total energy (kinetic plus potential) E of the particle. This should be a conserved quantity of the motion. Plot the energy error E(t) − E(0) as a function of time for 0 ≤ t ≤ 4 π for the time step δt obtained in part (c). (e) Using the value of δt determined in part (c), compute the period of the motion by finding the time taken for the particle to reach x = 0 again with v > 0. Use linear interpolation to refine your estimate, and compare your result with the analytic solution. (f) Repeat part (e) for v 0 = 0. 25 , 0. 5 , 1 , 2 , 4 , 8, and plot the numerically obtained period as a function of E(0).
a(x) = −k x^3 ,
again with k = 4.
In addition to answers to specific questions, for problems 2 and 3, turn in hardcopy of your programs and the output produced when they run, as well as all requested plots, with axes clearly labeled.