Ordinary Differential Equations

Exercise 8.7: Trajectory with air resistance
Many elementary mechanics problems deal with the physics of objects moving or flying through the air, but they almost always ignore friction and air resistance to make the equations solvable. If we’re using a computer, however, we don’t need solvable equations.
Consider, for instance, a spherical cannonball shot from a cannon standing on level ground. The air resistance on a moving sphere is a force in the opposite direction to the motion with magnitude

F = \frac{1}{2} \pi R^2\rho C v^2,

where R is the sphere’s radius, ρ is the density of air, v is the velocity, and C is the so-called coefficient of drag (a property of the shape of the moving object, in this case a sphere).

  1. Starting from Newton’s second law, F = ma, show that the equations of motion for the position (x, y) of the cannonball are

    \ddot{x} = - {\pi R^2\rho C\over2m}\, \dot{x}\sqrt{\dot{x}^2+\dot{y}^2},
    \ddot{y} = - g - {\pi R^2\rho C\over2m}\, \dot{y}\sqrt{\dot{x}^2+\dot{y}^2},

    where m is the mass of the cannonball, g is the acceleration due to gravity, and x ̇ and x ̈ are the first and second derivatives of x with respect to time.

  2. Change these two second-order equations into four first-order equations using the meth- ods you have learned, then write a program that solves the equations for a cannonball of mass 1 kg and radius 8 cm, shot at 30◦ to the horizontal with initial velocity 100 ms−1. The density of air is ρ = 1.22 kg m−3 and the coefficient of drag for a sphere is C = 0.47. Make a plot of the trajectory of the cannonball (i.e., a graph of y as a function of x).
  3. When one ignores air resistance, the distance traveled by a projectile does not depend on the mass of the projectile. In real life, however, mass certainly does make a difference. Use your program to estimate the total distance traveled (over horizontal ground) by the cannonball above, and then experiment with the program to determine whether the cannonball travels further if it is heavier or lighter. You could, for instance, plot a series of trajectories for cannonballs of different masses, or you could make a graph of distance traveled as a function of mass. Describe briefly what you discover.

Exercise 8.4:
Building on the results from Example 8.6 above, calculate the motion of a nonlinear pendulum as follows.

  1. Write a program to solve the two first-order equations, Eqs. (8.45)

    {d\theta \over dt} = \omega

    and (8.46)

    {d\omega \over dt} = -\frac{g}{l}\sin{\theta} ,

    using the fourth-order Runge–Kutta method for a pendulum with a 10 cm arm. Use your program to calculate the angle θ of displacement for several periods of the pendulum when it is released from a standstill at θ = 179° from the vertical. Make a graph of θ as a function of time.

  2. Extend your program to create an animation of the motion of the pendulum. Your animation should, at a minimum, include a representation of the moving pendulum bob and the pendulum arm. (Hint: You will probably find the function rate discussed in Section 3.5 useful for making your animation run at a sensible speed. Also, you may want to make the step size for your Runge–Kutta calculation smaller than the frame-rate of your animation, i.e., do several Runge–Kutta steps per frame on screen. This is certainly allowed and may help to make your calculation more accurate.)For a bigger challenge, take a look at Exercise 8.15 on page 398, which invites you to write a program to calculate the chaotic motion of the double pendulum.