Energy Conservation and Integration

The Area Under a Curve I: The Trapezoid Algorithm

In systems where energy is conserved, it is usually easier to solve problems by conserving energy than by using Newton's law. This is certainly true for relating velocity and position, and is true also, at least in principle, for relating time and position. The reason for this is that Newton's law is a second-order differential equation. In the case of a mass on a spring, the displacement and its second derivative appear as unknown functions in the same equation. There are well-established analytic techniques for solving such equations, and the Feynman algorithm deals with them numerically, but the energy approach is simpler in principle.

Energy conservation gives a relation between position and velocity directly:

We can rearrange this to give

And finally we transpose to get

The left-hand side gives time directly, and the right-hand side is the integral of a defined function of x. In principle, it is easier to integrate a known function than it is to find the unknown function that is the solution of a second-order differential equation. What makes the integration difficult in this case is the fact that at the turning points E = U(x), and the denominator of the integrand goes to zero. Before we tackle the turning point problem, let us look at the trapezoid algorithm, the technique commonly used to evaluate integrals of bounded functions.

The algorithm approximates the area under a curve by the sum of the areas of n trapezoids of equal width. The area of n trapezoids of width D x is

We can use this expression to evaluate our integral provided we stay away from the turning points. The example uses the algorithm to calculate the time it takes a mass on a spring, oscillating between turning points at x = 5 m and x = -5 m, to travel from x = -4 m to x = 4 m. The program plots the integrand with the left half divided into two trapezoids and the right half divided into four.

Java Source

When we double the number of trapezoids, we expect the error (the area between the trapezoids and the curve) to decrease by a factor of four, and the plot is reasonably consistent with this expectation. If this is true, we can write

The program calculates the area with 20 and 40 trapezoids, then uses the above expression to estimate a better value for comparison with the analytic value. (It also uses the algorithm discussed in the next section with 20 and 40 intervals to calculate 'Tvbar'.) The terms in the sum with n/2 intervals are included in the sum with n intervals, so the summation and estimation can be combined into a single procedure that is usually referred to as Simpson's Rule.