Equations of motion (2nd order ODEs)
We know that the motion of an object is determined by Newton’s equations. In the one-dimensional case, we can define the instantaneous position , velocity and acceleration of an object using the language of differential calculus: The motion of the particle is defined by: This is a second order differential equation that can written as two first order differential equations: To solve it we can apply any of the methods described in the previous sections. If we pick Euler’s, we obtain: where .
.
Forces acting on an object: a) moving upward b) falling.
Exercise 1.2: One dimensional motion
Write a program to solve the 1d equations of motion for a falling object. Input values: ; . Compare results with different and the exact solution. Plot and . Use ; .
This is a godd time to introduce the concept of objects and object oriented programming in Python. We will first define a class "particle"
We are now in position for a free falling particle:
Exercise 1.3: Air resistance
The form of the velocity-dependent force of the resistance of the air is given by where is a parameter that depends on the properties of the medium and the shape of the object. Since increases as increases, there is a limiting velocity at which and the acceleration vanishes: In terms of the terminal speed, the force can be rewritten as Hence, the net force on a falling object is:
Sometimes, the force can vary with the square of the velocity Derive the net force on a falling object using this expression, in units of the terminal velocity
Compute the speed at which a pebble of mass reaches the ground if it’s dropped from rest at . Compare this speed to that of a freely falling object under the same conditions. Assume that the drag force is proportional to and the terminal speed is
Supouse that an object is thrown vertically upward with initial velocity . If we neglect air resistance, we know that the maximum height reached by the object is , and its velocity upon return to the earth equals , the time of ascent equals the time of descent, and the total time in the air is . Before performing a numerical simulation, give a simple qualitative analysis of the problem when it is affected by the resistance of the air. Then, perform, the numerical calculation assuming with a terminal speed . Suggestions: Choose when it’s pointing upward, and when it’s pointing toward the earth.
The program will look pretty much identical to the previous one, but we need to introduce the drag force
Exercise 1.5: Gravitational force
According to Newton’s law of gravitation, the action of the gravitational field of the earth on a particle is given by where is measured from the earth’s surface, is the earth’s radius, is the gravitational constant, is the mass of the earth, and . There is not simple analytical solution for this problem. Modify your code to simulate the fall of a particle from an altitude with zero initial velocity, and compute its speed when it hits the ground. Determine the value of for which this impact velocity differs by one percent from its value under a constant acceleration . Take the radius of the earth to be .
Challenge 1.3:
Modify the previous code to introduce the a gravitational force that depends on the position, and solve Exercise 1.5
Exercise 1.6: Harmonic oscillator
The two coupled first order equations define a harmonic oscillator with period . Compute the position and momentum as a function of time using a generalization of the previous code. Plot the results for and =0. Investigate the accuracy with which the system returns to the initial state at integral values of .
Two dimensional trajectories
In a 2d trajectory, the direction of the drag force is opposite to the speed vector . Newton’s equations of motion for and components are written Using , and , we find where . Hence, we cannot calculate the vertical motion of the object without reference to the horizontal component.

Object in a two dimensional trajectory under the effect of gravitational and dragging forces}
Exercise 1.7: Trajectory of a shot
Modify your code so that the 2d trajectory of an object can be computed, and graphs of as a function of can be made.
As a check on your program, first neglect the effect of air resistance so that you an compare to known results. Supouse that the object is thrown and with an angle with an initial velocity m/s. Vary and show that the maximum range occurs at Compare your result with the exact value
Consider the effects of air resistance. Compute the maximum range, and the corresponding angle using , m/s.
Challenge 1.4:
Modify the previous code to include the effect of drag resistance, and solve Exercise 1.7, part 2.
An introduction to animations with matplotlib
Stability
A major consideration in integrating differential equations is the numerical stability of the algorithm used. Since we have replaced the differential equation by a difference equation, we know that our results will not be exact. Discrepancies will arise when using different step sizes, for instance. This is the “truncation error” and depends on the method employed. Other errors that do not originate in the method correspond to the roundoffs performed by the computer, since it does not work with real numbers, but with a finite number of digits determined by the hardware. These roundoff errors will accumulate and can become significant in some cases.
In practice we determine the accuracy of our solutions by reducing the value of the step until the solutions unchanged at the desired level of accuracy.
In addition to accuracy, another important factor is the stability of the algorithm. For instance, it may occur that the numerical results are very good for short times, but diverge from the “true” solution for longer times. Such an algorithm is said to be “unstable” for the particular problem.