0% found this document useful (0 votes)
13K views

Improper Integrals: Ü Two Ways To Classify

This document discusses improper integrals and numerical challenges in evaluating them. It covers two ways to classify improper integrals based on their domain and whether the integrand is oscillatory. It also explains why trapezoidal and Simpson's rules cannot be used for improper integrals that are not defined at endpoints. The document discusses numerical challenges like oscillatory integrals and integrals where the derivative is undefined at an endpoint. It provides examples of using Gauss-Legendre integration on improper integrals and explains how to change integrals with infinite domains to integrals with finite domains before numerical evaluation.

Uploaded by

Lovinf Florin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13K views

Improper Integrals: Ü Two Ways To Classify

This document discusses improper integrals and numerical challenges in evaluating them. It covers two ways to classify improper integrals based on their domain and whether the integrand is oscillatory. It also explains why trapezoidal and Simpson's rules cannot be used for improper integrals that are not defined at endpoints. The document discusses numerical challenges like oscillatory integrals and integrals where the derivative is undefined at an endpoint. It provides examples of using Gauss-Legendre integration on improper integrals and explains how to change integrals with infinite domains to integrals with finite domains before numerical evaluation.

Uploaded by

Lovinf Florin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

improper_integrals.

nb 1

Improper Integrals

ü Two ways to classify

Whenever we write Ÿa f (x) „ x we assume that f HxL is continuous on the open interval Ha, bL. The integral is improper if a
b

or b is infinite or if f is undefined at a or b.

One classification is finite or infinite domain, depending on whether a and b are both finite or at least one is infinite. The

at an infinite number of points in Ha, bL.


other classification is whether or not the integrand in oscillatory, which we will say corresponds to f ' being 0 or undefined

An example of an improper integral on a finite domain is:

è!!! ƒƒ 1
ƒƒ
‡ ÅÅÅÅÅÅÅÅ
è!!!ÅÅÅÅÅ „ x = 2 x ƒƒ = 2
ƒƒ 0
1
1
0 x

An example of an improper integral on an infinite domain is:

-1 ƒƒƒ ¶
‡ ÅÅÅÅ2ÅÅ „ t = ÅÅÅÅÅÅÅÅÅÅ ƒƒƒƒ

t ƒ 1
1
= 1
1 t

Both of these examples are non-oscillatory. An example of an oscillatory integral is:



sin x
ÅÅÅÅÅÅÅÅÅÅÅÅÅÅ „ x
0 x

Of course not all improper integrals converge, for example:

‡ ÅÅÅÅÅ
1
1
„x
0 x

and



1
ÅÅÅÅÅ „ x
1 x

ü Why Trapezoidal and Simpson's methods cannot be used for improper integrals

The trapezoidal and Simpson's methods use the value of the integrand at the endpoints of the domain of integration. If the
function is not defined there, these methods cannot be used. The midpoint and Gauss-Legendre methods use only interior
points, so these are better suited to improper integrals. However, as we will see, that these methods always return a result is
not necessarily a good thing. Interior point methods return finite values when applied to both convergent and divergent
integrals. It is something of an art to decide when an integral is divergent or how accurately the numerical value returned
matches the integral.
improper_integrals.nb 2

ü Numerical Challenges of Improper Integrals

Improper integrals present great challenges for numerical integration, but they are important in certain parts of science like
physics. Oscillatory integrals are generally much harder than non-oscillatory integrals, and we will not consider them until
the end of this section.

There is one kind of proper integral which also causes problems for numerical integration, one in which the first or higher
derivative of the integrand is undefined at an endpoint. Numerical integration methods depend on functions being "like"
polynomials, and functions with undefined derivatives are not like polynomials.

1 è!!!
Let's look at an example: Ÿ0 x „ x. This is a proper integral, but the first derivative of the integrand vanishes at 0. We can
integrate exactly using the Fundamental Theorem of Calculus:

è!!! 2 3 ƒƒƒ 1
‡ x „ x = ÅÅÅÅÅ x ÅÅ2ÅÅ ƒƒƒƒ
ƒ0
1
2
= ÅÅÅÅÅ
0 3 3

Let's try numerical methods on this integral, starting with the midpoint method with 20 subdivisions. We start by defining
the midpoint method:

SumAf@xD, 9x, a + =E
b−a b−a b−a
In[90]:= midpoint@f_, a_, b_, n_D := , b,
n 2n n

Now apply the midpoint method to our integral:

In[91]:= f@x_D := Sqrt@xD


midpoint@f, 0., 1., 20D

Out[92]= 0.667295

Not a great answer. Let's try Gauss-Legendre integration with 20 subdivisions. Remember the Gauss-Legendre integrator
from previous notes:

gaussLegendre@f_, a_, b_, gc_D :=


b−a i a+b
gc@@i, 1DDEy
In[93]:=

j
jfA z
z,
b−a a+b b−a
2 k {
SumAgc@@i, 2DD − gc@@i, 1DDE + fA +

8i, 1, Length@gcD<E
2 2 2 2

Next we import the Gauss-Legendre coefficients from:

http://www.math.ntnu.no/num/nnm/Program/Numlibc/gauss_co.c
improper_integrals.nb 3

gc20 = 880.993128599185094, 0.017614007139152<, 80.963971927277913, 0.040601429800386<,


80.912234428251325, 0.062672048334109<, 80.839116971822218, 0.083276741576704<,
In[94]:=

80.746331906460150, 0.101930119817240<, 80.636053680726515, 0.118194531961518<,


80.510867001950827, 0.131688638449176<, 80.373706088715419, 0.142096109318382<,
80.227785851141645, 0.149172986472603<, 80.076526521133497, 0.152753387130725<<;
gaussLegendre@f, 0., 1., gc20D

Out[95]= 0.666679

As usual, the Gauss-Legendre method produces a better result than the midpoint method but not as good as we might
expect from past experience. As always, to know how accurate your result is you should calculate it several ways and only
trust the answers that agree with each other.

ü Changing from infinte domains to finite domains of integration

Improper integrals are even more difficult for numerical methods. For a start, you can't even approximate an improper
integral with infinite domain, because you can't know at what points to evaluate the function. Any time you encounter an
integral with infinte domain, you must use a change of variable to change it to one with finite domain before applying
numerical methods. Here's an example:
ƒƒ ¶
ƒ
‡ e-x „ x = -e-x ƒƒƒƒ

ƒ 0
= 1
0

First we break the integral into two parts, a proper integral and an improper integral with infinite domain:

‡ e-x „ x = ‡ e-x „ x + ‡
¶ 1 ¶
e-x „ x
0 0 1

-1
Next we change the improper part to an integral on a finite domain, using the transform x = ÅÅÅÅ1t , dx = ÅÅÅÅ
ÅÅÅÅ dt:
t2

‡ e-x „ x = ‡ ÅÅÅÅÅÅÅÅ
-1
¶ 1 ÅÅÅÅtÅÅÅ
e
ÅÅÅÅ „ t
1 0 t2

Note that the resulting integral is proper, since the integrand does not go to infinity at either end of the domain of
integration.
improper_integrals.nb 4

, 8t, 0, 1<E
−1
E t
In[96]:= PlotA
t2

0.5

0.4

0.3

0.2

0.1

0.2 0.4 0.6 0.8 1

Out[96]= Graphics

Let's calculate Ÿ0 e-x „ x using the 20-point Gauss-Legendre approximation on both parts.

In[97]:= f@x_D := E−x


−1
E x
g@x_D :=

gaussLegendre@f, 0, 1, gc20D + gaussLegendre@g, 0, 1, gc20D êê InputForm


x2

Out[99]//InputForm=
1.00000015715476

ü Using the Gauss-Legendre method of improper integrals with finite domains

Let's try the 20-point and 40-point Gauss-Legendre method on two improper integrals, which which is convergent and one
which is not.

A = ‡ ÅÅÅÅÅÅÅÅ
è!!!ÅÅÅÅÅ „ x
1
1
0 x

B = ‡ ÅÅÅÅÅ „ x
1
1
0 x
improper_integrals.nb 5

gc40 = 880.998237709710559, 0.004521277098533<, 80.990726238699457, 0.010498284531152<,


In[100]:=

80.977259949983774, 0.016421058381907<, 80.957916819213791, 0.022245849194166<,


80.932812808278676, 0.027937006980023<, 80.902098806968874, 0.033460195282547<,
80.865959503212259, 0.038782167974472<, 80.824612230833311, 0.043870908185673<,
80.778305651426519, 0.048695807635072<, 80.727318255189927, 0.053227846983936<,
80.671956684614179, 0.057439769099391<, 80.612553889667980, 0.061306242492928<,
80.549467125095128, 0.064804013456601<, 80.483075801686178, 0.067912045815233<,
80.413779204371605, 0.070611647391286<, 80.341994090825758, 0.072886582395804<,
80.268152185007253, 0.074723169057968<, 80.192697580701371, 0.076110361900626<,
80.116084070675255, 0.077039818164247<, 80.038772417506050, 0.077505947978424<<;

f@t_D := è!!!!
1
t
1
g@t_D :=
t
A20 = gaussLegendre@f, 0, 1, gc20D
A40 = gaussLegendre@f, 0, 1, gc40D
B20 = gaussLegendre@g, 0, 1, gc20D
B40 = gaussLegendre@g, 0, 1, gc40D

Out[103]=
1.95753

Out[104]=
1.9785

Out[105]=
7.19548

Out[106]=
8.55709

Thinking intuitively, you can see that the two estimates for Ÿ0 ÅÅÅÅ
è!!!
ÅÅÅÅ!ÅÅ „ x are fairly close together; you could expect that the
11

integral converges to a value not too different from the computed values. On the other hand the two estimates for Ÿ0 ÅÅÅÅ1x „ x
x
1

are very different, leading to the suspicion that maybe the integral does not converge at all.

ü A better way to calculate improper integrals: Adaptive Integration

We could get a better value for a convergent improper integral by using more and more points with the Gauss-Legendre
method, but that is wasteful. Generally speaking, an improper integral is easy to calculate away from its singularity or bad
point. For example:

è!!! ƒƒƒƒ 1
‡ è!!!ÅÅÅÅÅ „ x = 2 x ƒƒƒƒ 0.1 = 1.36754
1
1
ÅÅÅÅÅÅÅÅ
0.1 x

yields readily to the 20-point Gauss-Legendre method. The 20-point Gauss-Legendre approximation for this integral is:
improper_integrals.nb 6

In[107]:=
gaussLegendre@f, 0.1, 1, gc20D

Out[107]=
1.36754

We want to use lots of points to approximate the integral near its singularity but not so many elsewhere. Here's an idea: do
three approximations:

Rº ‡ f HxL „ x
b

Sº‡ f HxL „ x
a+b
ÅÅÅÅ
2ÅÅÅÅÅÅ

T º ‡ f HxL „ x
b

a+b
ÅÅÅÅ2ÅÅÅÅÅÅ

We expect R º S + T, and if the equation holds with reasonable accuracy then we can accept S + T as the correct integral.
(In general R, S and T will have been calculated with the same method and number of points, so the sum S + T is calculated
with twice as many points as R and therefore is probably more accurate.) If the two values are not close enough together,
we try to calculate S and T separately, using the same divide-and-conquer method. This is called the adaptive method of
numerical integration. It puts more effort into those parts of the domain where the integral is hard to calculate. The best way
to express the algorithm is through recursion. Note the parameter "remainingIterations" that prevents infinite recursive calls.

First we give the algorithm is pseudo-code. We assume the existence of a method of approximating integrals called numeri-
calIntegral(f,a,b) that uses only interior points. This might be a midpoint or Romberg or Gauss-Legendre method with a
fixed number of points.

Function adaptiveIntegral(f,a,b,precision,remainingInterations)
if remainingIterations = 0 then
Print "Adaptive integration failed on the interval [a,b]"
Return(-1)
exit
endif
R = numericalIntegral(f,a,b)
S = numericalIntegral(f,a,(a+b)/2)
T = numericalIntegral(f,(a+b)/2,b)
if abs(R-(S+T)) < precision then
return(S+T)
else
return(adaptiveIntegral(f,a,(a+b)/2,precision,remainingInterations-1)
+adaptiveIntegral(f,(a+b)/2,b,precision,remainingInterations-1))
endif
end

Let's try this in Mathematica. We will use the 20-point Gauss-Legendre method for numericalIntegral. I'm going to add a
line to trace the iterations. I'm also going to eliminate a major inefficiency. In the pseudocode, when we call adaptive-
Integral(f,a,(a+b)/2,precision,remainingInterations-1) , we calculate numericalIntegral(f,a,(a+b)/2). Be we calculated that
just before the recursive call, so let's pass the value as part of the recursion.
improper_integrals.nb 7

In[108]:=
adaptiveIntegral@f_, a_, b_, integralA2B_,

8r, s, t<,
precision_, remainingIterations_, firstIteration_D := Module@

Print@"Adaptive integration failed on interval @", a, ", ", b, "D"D;


If@remainingIterations 0,

Return@−1D,
If@firstIteration,
r = gaussLegendre@f, a, b, gc20D,
r = integralA2B
D;
s = gaussLegendre@f, a, Ha + bL ê 2, gc20D;
t = gaussLegendre@f, Ha + bL ê 2, b, gc20D;
H∗ Print@8a,b,Abs@r−Hs+tLD<D; ∗L
If@Abs@r − Hs + tLD < precision,
Return@s + tD,

adaptiveIntegral@f, a, Ha + bL ê 2, s, precision, remainingIterations − 1, FalseD


Return@

+ adaptiveIntegral@f, Ha + bL ê 2, b, t, precision, remainingIterations − 1, FalseDD


D
D
D

Let's try it on

‡ ÅÅÅÅÅÅÅÅ
è!!!ÅÅÅÅÅ „ x = 2
1
1
0 x
In[109]:=
adaptiveIntegral@f, 0, 1, 0, 0.0001, 20, TrueD

Out[109]=
1.99977

Now let's try a divergent integral: Ÿ0 ÅÅÅÅ1x „ x


1

In[111]:=
adaptiveIntegral@g, 0, 1, 0, 0.0001, 20, TrueD

Adaptive integration failed on interval @0, D


1
1048576

Adaptive integration failed on interval @ D


1 1
,
1048576 524288
Out[111]=
11.1698

You might also like