# Introduction to Numerical Integration

Since the time of Newton, the ability to integrate and differentiate has been of paramount importance in science and engineering applications. For most of you, the first time you encountered integrals and derivatives were in the context of Newton's equations of motion.

For example, instantaneous velocity is defined as the first derivative, with respect to time, of displacement:

Similarly, if we know velocity as a function of time, we can obtain displacement by taking the anti-derivative or integral of velocity:

If the velocity is constant (i.e. the acceleration is zero), then the displacement can be expressed algebraically as

See this for an illustration of this situation. Notice that the displacement can be understood graphically as the area under the velocity curve.

Alternatively, if a constant force is at work and is producing acceleration at a constant rate a, then the displacement is given by

If we let , start our clocks at , and assume our initial displacement and velocity are zero, we obtain the familiar formula relating displacement and acceleration:

The displacement can still be represented by an area, but this time the relationship is a little more complicated. As Newton noted, the value is equal to the area under the curve. See this for an illustration.

So in general, we can describe the definite integral of a function f between a and b

to be the area between f(x) and the x-axis in the region between the endpoints (bounds) a and b. See this for an illustration.

The evaluation of integrals by numerical means was undertaken long before the invention of computers. This was because scientists and engineers quickly found that a large number of physical problems gave rise to integrals which could not be evaluated in closed form. This meant that if the scientist wanted to obtain an answer to such a problem the scientist had to find an approximate value to the integral.

We have already seen that the value of an integral can be obtained by measuring the area between the integrand and the x-axis. The idea behind numerical integration is that by approximating this area, we can approximate the integral. In this lesson we will study the two most basic techniques for numerical integration: the rectangular method and the trapezoidal method. Along the way we'll add to our repertoire of C statements by using the for statement.

Click on the button below to copy today's example files into your examples directory.

Click to copy the example files.

Christopher R. Johnson
Hamlet Project
Department of Computer Science
University of Utah