Vous êtes sur la page 1sur 10

1

Chapter 5 Some Special Functions, and Numerical Integration

Just as we have seen that numerical methods can aid us in calculating derivatives or solving dierential equations, there are methods that can help us with integration as well.

Given combinations of basic functions, it is generally not dicult for us to use derivative rules to dierentiate, even if the result is quite complicated. On the other hand, as we have seen in past math courses, there really are no general rules for integration. In fact, some integrals are simply impossible to solve, because they do not have solutions that can be written down with other functions that we are familiar with. Lets start this section by exploring some of these interesting functions.

5.1

Some Special Functions

Consider ex dx or
2

(5.1)

e x dx. (5.2) x Both of these integrals arise commonly in various situations, and yet neither of them is actually solvable. The rst comes up so commonly and is so vital to statistics that it has been given a name that stems from its use in that eld. Well, almost: The error function of x is denoted
x 2 2 erf(x) = et dt. (5.3) 0 Looking rst at the integrand, from what we know about the basic exponential

function (or by taking a look at the graph of positive:

2 t2 e ),

it is obvious that it is always

2 The maximum on the graph occurs at x = 0, where the height is the graph is even (i.e. f (x) = f (x) for any x R).

1.1284, and

Now, the integral in the denition runs from 0 to x, and thus when x is positive, the function we simply obtain the area under this function between 0 and x. When the

3 x in the function is negative, the bounds run from 0 to x, but since 0 > x, we receive the negative of the area (by integral properties). Thus, erf(x) is negative for x < 0 and positive for x > 0. Finally, 2 erf(0) =
0 0

et dt = 0,

(5.4)

so the graph runs through the origin. Thus, we have established all sorts of properties about this function without actually being able to write it down beyond the integral! In fact, the graph of erf(x) looks like this:

It is an odd graph, which is easily seen, and it has asymptotes of 1. Thus, this function has the very special property that: 2 lim erf(a) = a while 2 lim erf(a) = a
0 0

et dt = 1,

(5.5)

et dt = 1.

(5.6)

4 This makes it very useful in describing certain statistical distributions (it is involved in the integral of the standard normal distribution, in fact!). But evaluating this at any point in particular between 0 and is dicult, because the denition of the function itself involves an integral that we cannot solve using the techniques we know so far!

The next function we will look at is named for its integrand and is notorious for its inability to be integrated. The exponential integral is dened as:

Ei(x) =
x

et dt. t

(5.7)

This integral is improper and may also have bounds that lie on either side of the discontinuity at x = 0. So it would need special considerations to be dealt with directly; however, there is no direct way to nd an antiderivative anyway. Lets take a look at the integrand anyway, to try and draw this function. ex , and obtain some perspective for x

Lets try rst to graph the function f (x) = what is happening here:

The graph of ex is straightforward. It is always positive, and always decreasing; The rational function asymptote y = 0. Dividing the second into the rst blends the behaviours in ways we might expect: 1 has vertical asymptote x = 0 and a horizontal x

et dt, which has a lot of x t really irritating negative signs in inconvenient places. Still, lets look at this one Now, lets consider the original function: Ei(x) = case at a time: For negative values of x, we have an integral with bounds between a positive number to . With the above function, in the integrand, being always positive, the integral should be positive for negative values of x; and thus the negative of that integral, as is dened in the function, leads us to expect that Ei(x) should be always < 0 for negative values of x. The function et as t 0+ , and in fact, Ei(x) diverges when x = 0. t That is, Ei(0) does not exist!

For positive values of x, Ei(x) becomes an integral with bounds that straddle the discontinuity at x = 0, with the x bound becoming negative. ex Considering the graph above of , we are now adding negative area to the x unbounded positive area between 0 and : It turns out that this integral

6 DOES converge, but we dont go into more details about that here; also, at some value of x, the positive and negative areas on each side of the discontinuity are equal; at this point, Ei(x) should have a root! Then, it should continue to increase as we continue to add negative area (remembering that the whole integral is slapped by a negative sign). A bit of a mouthful, to be sure, but the graph of Ei(x) looks like this in the end:

Regardless, there is again no easy way to evaluate this function at any point, again because of our inability to nd the antiderivative. So what do we do?

There are lots of other functions that have this kind of issue, but its about time that we make some decisions on what to do about it. We will start from the most basic methods of approximating integrals, and build from there.

5.2

Riemann Sums

First, we review Riemann Sums. As this concept is found in almost any introductory calculus course, it provides a good background of how the approximation of denite integrals will tend to work! The problem is very simple: Given the denite integral
b

f (x) dx
a

(5.8)

nd the area below the function y = f (x) and above the x-axis between x = a and x = b. (Here, f (x) is assumed to be positive. For negative f (x), this process gives the negative of the area below the x-axis and above y = f (x).

The Riemann Sum is created by the following process: First create a partition P of the interval [a, b], dividing it into n subintervals; Dene an evaluation point xi in each subinterval, for i = 1, . . . , n for which we consider a height f (xi ); Sum the areas of the n rectangles with width equal to the width of subinterval i and height of f (xi ).

We recall that the denite integral is dened by the limit of the areas of the rectangles making up a Riemann Sum as the largest subinterval approaches 0 width

8 (and the number of rectangles lling the interval approaches innity!); the nite Riemann Sum itself provides at least a rough estimate for the area.

Example: Estimate the denite integral


0

sin(x2 ) dx

(5.9)

using a Riemann Sum with four equal subintervals, using the left endpoints of each subinterval as the evaluation points.

Solution: The four subintervals go from: 0 to 4 to 4 2 3 to 2 4 3 to 4 The evaluation points are stipulated to be the left endpoints of each subinterval; thus the sum is given by 2 sin(x ) dx ( )(sin(0)) + sin + sin + 4 4 16 4 4 0 9 sin + 4 16 = 0 + (0.4431)(0.08645) + (0.4431)(0.7071) + (0.4431)(0.9808) = 0.7862 The Riemann Sum only provides a rough estimate, but it does generally improve as the number of rectangles increases. There are better methods, though!

5.3

Trapezoid Rule

The trapezoid rule puts a bit of a spin on a Riemann Sum. Why use the areas of rectangles to approximate the sums? The trapezoid rule provides a much better estimate of a denite integral by making some slight alterations to the scheme. First create a partition P of the interval [a, b], dividing it into n subintervals; Dene x0 = a as the left endpoint of the rst subinterval, with increasing index for each subsequent subinterval so that xn = b; Create the trapezoid over each subinterval between xi1 and xi , for i = 0, 1, . . . , n, created by using the heights of the function, f (xi1 ) and f (xi ). Sum the areas of the n trapezoids. Recall that the area of a trapezoid of height h with long parallel side p and short parallel side q is given by: 1 ph + qh = h(p + q ). 2 2 Thus, applying this to our problem, the area of the ith trapezoid is given by Area = (5.10)

1 Area = (xi xi1 )(f (xi1 ) + f (xi )) (5.11) 2 Supposing that all of the subintervals are the same width (given by h, perhaps), then the area reduces nicely to 1 Area = h(f (xi1 ) + f (xi )) (5.12) 2 To illustrate, suppose that we had two subintervals, created by three points x0 , x1 , and x2 , and thus two trapezoids to sum up. Then 1 1 h(f (x0 ) + f (x1 )) + h(f (x1 ) + f (x2 )) 2 2 1 = h(f (x0 ) + 2f (x1 ) + f (x2 )). 2

Area =

(5.13) (5.14)

10 We can see that the outer points only get counted once, while the middle points will all get double-counted. In this way, we can extend our formula to the case where we have n subintervals, and thus n trapezoid areas to sum up:

Trapezoid Rule: Given the framework from above, and assuming a constant subinterval length of h,
b

the denite integral


a b

f (x) dx can be approximated by: 1 h(f (x0 ) + 2f (x1 ) + . . . + 2f (xn1 ) + f (xn )) 2

f (x) dx
a

(5.15)

Example:
6

Approximate
1

ex dx using trapezoid rule and a uniform stepsize of h = 1. x

Using the stepsize in the problem, our partition consists of ve subintervals, created by points x0 = 1, x1 = 2, x2 = 3, x3 = 4, x4 = 5, and x5 = 6. Trapezoid rule gives us:

6 1

ex 1 e1 e2 e3 e4 e5 e6 dx = (1) +2 +2 +2 +2 + (5.16) x 2 1 2 3 4 5 6 = 0.3679 + 0.1353 + 0.03319 + 0.009158 + 0.001348 + 0.0004131 (5.17) 0.5473 (5.18)

Vous aimerez peut-être aussi