A Short Dissertation on Numerical Integration

Total Page:16

File Type:pdf, Size:1020Kb

A Short Dissertation on Numerical Integration

A Short Dissertation on Integrating Irregular Functions: Numerical Integration and Curve Fits -by Peter Andersen

There are three very commonly used methods for integrating functions that are not associated with a well-defined analytical function. I will go over each.

1) Using a simple Riemann sum Approximation. Remember from basic calculus that the fundamental theorem of calculus is derived from this method. Basically, this method consists of breaking the function into small subintervals and evaluating the function at each subinterval. The area of one subinterval is then f(x)*dx. This method, however, will in general give an “over shot”/”undershot” value for the area, depending on the f(x) chosen. Perhaps a pictorial description would be more helpful. a: Choosing the first value b: Choosing the second value

f(x) f(x)

|dx |

**it can be easily seen that if dx is “small” the error is also small. **Additionally, it can be (quite easily) shown that the trapezoidal method reduces these errors by effectively taking the average of the two methods.

FIGURE 1: comparison of choosing upper and lower bounds on Reimann Sum

2) Using what is called the Trapezoidal Method. This is an expansion/refinement on the Reimann sum. Where the Reimann sum assumes a constant value on the subinterval, (a zero’th order approximation), the Trapezoidal method consists of assuming a linear solution over the element—thereby obtaining a more accurate solution. In fact, with sufficiently smooth curve, and with sufficiently small intervals, this approximation is VERY good. This method can be easily implemented in a spreadsheet, as one can easily obtain that the area of the trapezoidal element is equal to ½[f(x)+f(x+dx)]*dx. Alternatively, many computer programs have a built in function to do it (somewhat mindlessly), notably Matlab, with the ‘trapz’ command.

3) The third and generally least accurate method is to assume a solution form OVER THE ENTIRE DOMAIN, (e.g. 2nd order polynomial, logarithmic, etc), fit a ‘least squares fit’ curve of the assumed form, and then simply use analytical integration to evaluate the area. This method is easy to do using common functions using many current spreadsheet applications, but generally depends on a heuristic idea about the type of relation to be obtained. Additionally, only a limited number of function types are generally given. These types of functions are all easily integrated, but may not be indicative of the particular function under consideration.

a: The Trapezoidal Method effectively b: The “curve fit” method can be very uses the AVERAGE value of Inaccurate f(x), and does a Reimann Sum

FIGURE 2: Trapezoidal method and ‘curve fit’ method

Thus, for purposes of this lab, use the trapezoidal method. However, it may be interesting (and not entirely difficult) to use other methods and compare the accuracy of these methods to the trapezoidal method. For instance, a percent error in the Curve Fit method can be found as:

ACurve  ATtrapezoid  %  Fit EQUATION 1 ATrapezoid This may be an interesting way to extend your study and check the numerical values of your numerical methods. This is important because a factor could easily be off in the spreadsheet, yielding large errors. However, integrating a 3rd order polynomial, for example, is not difficult and should differ by ±20% or less.

Recommended publications