Upload
vithursan-thangarasa
View
222
Download
0
Embed Size (px)
Citation preview
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
1/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 differential equations, there are methods that can help us with integration
as well.
Given combinations of basic functions, it is generally not difficult for us to use
derivative rules to differentiate, even if the result is quite complicated. On the otherhand, 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
2
dx (5.1)
or
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
2/10
2
ex
x
dx. (5.2)
Both of these integrals arise commonly in various situations, and yet neither of
them is actually solvable. The first comes up so commonly and is so vital to statistics
that it has been given a name that stems from its use in that field. Well, almost: The
error functionofxis denoted
erf(x) = 2
x
0
et2
dt. (5.3)
Looking first at the integrand, from what we know about the basic exponential
function (or by taking a look at the graph of 2
et2
), it is obvious that it is always
positive:
The maximum on the graph occurs at x= 0, where the height is 2
1.1284, and
the graph is even (i.e. f(x) =f(x) for any x R).
Now, the integral in the definition runs from 0 to x, and thus when xis positive, the
function we simply obtain the area under this function between 0 and x. When the
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
3/10
3
xin 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. Finally,
erf(0) = 2
0
0
et2
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 of1. Thus, thisfunction has the very special property that:
lima
erf(a) = 2
0
et2
dt= 1, (5.5)
while
lima
erf(a) = 2
0
et2
dt= 1. (5.6)
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
4/10
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 difficult, because the definition of thefunction 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 defined as:
Ei(x) = x
et
t dt. (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 find an antiderivative anyway. Lets take
a look at the integrand anyway, to try and draw this function.
Lets try first to graph the function f(x) = ex
x , and obtain some perspective for
what is happening here:
The graph ofex is straightforward. It is always positive, and alwaysdecreasing;
The rational function 1x
has vertical asymptote x= 0 and a horizontal
asymptote y= 0.
Dividing the second into the first blends the behaviours in ways we mightexpect:
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
5/10
5
Now, lets consider the original function: Ei(x) = x
et
t dt, which has a lot of
really irritating negative signs in inconvenient places. Still, lets look at this one
case at a time:
For negative values ofx, we have an integral with bounds between a positivenumber to. With the above function, in the integrand, being alwayspositive, the integral should be positive for negative values ofx; and thus the
negativeof that integral, as is defined in the function, leads us to expect that
Ei(x) should be always
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
6/10
6
DOES converge, but we dont go into more details about that here; also, at
some value ofx, 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 ofEi(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 find 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.
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
7/10
7
5.2 Riemann Sums
First, we review Riemann Sums. As this concept is found in almost anyintroductory calculus course, it provides a good background of how the
approximation of definite integrals will tend to work!
The problem is very simple: Given the definite integral
b
a
f(x) dx (5.8)
find the area below the functiony = f(x) and above thex-axis betweenx= a and
x= b. (Here, f(x) is assumed to be positive. For negativef(x), this process gives
the negative of the area below thex-axis and abovey= f(x).
The Riemann Sum is created by the following process:
First create a partitionPof the interval [a, b], dividing it into nsubintervals;
Define an evaluation point xi in each subinterval, for i= 1, . . . , nfor which we
consider a height f(xi);
Sum the areas of the nrectangles with width equal to the width of subintervali and height off(xi).
We recall that the definite integral isdefinedby the limit of the areas of the
rectangles making up a Riemann Sum as the largest subinterval approaches 0 width
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
8/10
8
(and the number of rectangles filling the interval approaches infinity!); the finite
Riemann Sum itself provides at least a rough estimate for the area.
Example:
Estimate the definite 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
4 to
2
2 to
3
4
3
4 to
The evaluation points are stipulated to be the left endpoints of each subinterval;
thus the sum is given by
0
sin(x2) dx (
4 )(sin(0)) +
4
sin
16
+
4
sin
4
+
+
4sin9
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!
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
9/10
9
5.3 Trapezoid Rule
The trapezoid rule puts a bit of a spin on a Riemann Sum. Why use the areas ofrectangles to approximate the sums? The trapezoid rule provides a much better
estimate of a definite integral by making some slight alterations to the scheme.
First create a partitionPof the interval [a, b], dividing it into nsubintervals;
Define x0=a as the left endpoint of the first subinterval, with increasingindex for each subsequent subinterval so that xn=b;
Create the trapezoid over each subinterval between xi1 and xi, fori= 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 hwith long parallel side pand short
parallel sideqis given by:
Area = ph+qh
2
=1
2
h(p+q). (5.10)
Thus, applying this to our problem, the area of the ith trapezoid is given by
Area =1
2(xi xi1)(f(xi1) + f(xi)) (5.11)
Supposing that all of the subintervals are the same width (given by h, perhaps),
then the area reduces nicely to
Area =1
2
h(f(xi1) +f(xi)) (5.12)
To illustrate, suppose that we had two subintervals, created by three points x0, x1,
and x2, and thus two trapezoids to sum up. Then
Area = 1
2h(f(x0) + f(x1)) +
1
2h(f(x1) + f(x2)) (5.13)
= 1
2h(f(x0) + 2f(x1) + f(x2)). (5.14)
8/12/2019 Special+Functions,+Riemann+Sums,+Trapezoid+Rule
10/10
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 ofh,
the definite integral
b
a
f(x) dxcan be approximated by:
b
a
f(x) dx 1
2h(f(x0) + 2f(x1) +. . .+ 2f(xn
1) +f(xn)) (5.15)
Example:
Approximate
6
1
ex
x dx using trapezoid rule and a uniform stepsize ofh= 1.
Using the stepsize in the problem, our partition consists of five subintervals, created
by points x0= 1, x1= 2, x2= 3, x3= 4, x4= 5, and x5= 6. Trapezoid rule gives
us:
6
1
ex
x dx =
1
2(1)
e1
1 + 2
e2
2 + 2
e3
3 + 2
e4
4 + 2
e5
5 +
e6
6
(5.16)
= 0.3679 + 0.1353 + 0.03319 + 0.009158 + 0.001348 + 0.0004131(5.17)
0.5473 (5.18)