Docsity

Numerical Integration Methods - Homework 2 | AMSC 660, Assignments of Mathematics

Toggle sidebar
bg1
CMSC/AMSC 660-0101 Fall 2004
Homework 2
Show all work.
All work must be your own (i.e., no group efforts are allowed).
If you use a reference book, cite it, or you will lose credit!
Each problem is worth 10 points. Work 5 problems only, for a maximum
score of 50 points. (If you hand in more than 5, I’ll grade the first 5.)
Due: Before class, October 5.
Numerical analysis textbooks provide excellent advice on approximating
integrals over low dimensional spaces, but many problems of interest are
naturally posed in high dimensions and yield integrals over regions with a
large number of variables. These problems arise, for example, in evaluating
the failure rate of materials, the expected return on an investment, or the
expected value of the energy of a system with a large number of particles. In
this homework, we study some algorithms appropriate for these problems,
using a system of particles as a motivating example.
Understanding the behavior of particles subjected to forces is a basic theme in
physics. The simplest system is a set of particles confined to motion along a
line, but even this system presents computational challenges. For the harmonic
oscillator, a particle is subjected to a force directed toward the origin and pro-
portional to the distance between the particle and the origin. The resulting
potential is V(x)=−1
2
αx2where αis a constant. This system is quite thor-
oughly understood, and quantities of interest can be computed in closed form.
Alternatively, the Ginzburg-Landau anharmonic potential −1
2αx2+1
4βx4(α
and βconstant) is related to solution of the Schr¨odinger equation, and quan-
tities of interest are computed approximately. One method of obtaining such
approximations is numerical integration, and that is our focus in this home-
work.
A system in thermodynamic equilibrium can be characterized by its partition
function, an expression for the expected value of eraised to a power equal to
the energy of the system divided by a normalization parameter αT . From the
partition function, many quantities of interest can be computed; for example,
the expected value of the energy, the free energy, the entropy, etc., so it is a
quite important function to compute.
Consider a chain of particles in which each particle interacts with its one or
two neighbors on the chain. For this set of particles, the partition function is
Zd(L)=Z∞
−∞
ρ(a, a, L)da (1)
where L=1/(αT ), Tis the temperature, αis the Boltzmann constant, dis
the number of particles, and ρis
ρd(a, b, L)=Z∞
−∞ Z∞
−∞
...Z∞
−∞
g(a, x1,L)g(x
1,x
2,L)...g(x
d,b,L)dx1dx2...dx
d
where
g(x, y, L)= 1
√
2πδ exp −1
2δ(x−y)2−1
2δ(V(x)+V(y))
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Numerical Integration Methods - Homework 2 | AMSC 660 and more Assignments Mathematics in PDF only on Docsity!

CMSC/AMSC 660-0101 Fall 2004 Homework 2 Show all work. All work must be your own (i.e., no group efforts are allowed). If you use a reference book, cite it, or you will lose credit! Each problem is worth 10 points. Work 5 problems only, for a maximum score of 50 points. (If you hand in more than 5, I’ll grade the first 5.)

Due: Before class, October 5.

Numerical analysis textbooks provide excellent advice on approximating integrals over low dimensional spaces, but many problems of interest are naturally posed in high dimensions and yield integrals over regions with a large number of variables. These problems arise, for example, in evaluating the failure rate of materials, the expected return on an investment, or the expected value of the energy of a system with a large number of particles. In this homework, we study some algorithms appropriate for these problems, using a system of particles as a motivating example.

Understanding the behavior of particles subjected to forces is a basic theme in physics. The simplest system is a set of particles confined to motion along a line, but even this system presents computational challenges. For the harmonic oscillator, a particle is subjected to a force directed toward the origin and pro- portional to the distance between the particle and the origin. The resulting potential is V (x) = − 12 αx^2 where α is a constant. This system is quite thor- oughly understood, and quantities of interest can be computed in closed form. Alternatively, the Ginzburg-Landau anharmonic potential − 12 αx^2 + 14 βx^4 (α and β constant) is related to solution of the Schr¨odinger equation, and quan- tities of interest are computed approximately. One method of obtaining such approximations is numerical integration, and that is our focus in this home- work.

A system in thermodynamic equilibrium can be characterized by its partition function, an expression for the expected value of e raised to a power equal to the energy of the system divided by a normalization parameter αT. From the partition function, many quantities of interest can be computed; for example, the expected value of the energy, the free energy, the entropy, etc., so it is a quite important function to compute.

Consider a chain of particles in which each particle interacts with its one or two neighbors on the chain. For this set of particles, the partition function is

Zd(L) =

−∞

ρ(a, a, L)da (1)

where L = 1/(αT ), T is the temperature, α is the Boltzmann constant, d is the number of particles, and ρ is

ρd(a, b, L) =

−∞

−∞

−∞

g(a, x 1 , L)g(x 1 , x 2 , L)... g(xd, b, L)dx 1 dx 2... dxd

where

g(x, y, L) =

2 πδ

exp

2 δ

(x − y)^2 −

δ(V (x) + V (y))

with δ = L/(d + 1). Let’s develop some algorithms for approximating Zd(L).

Numerical Integration Methods

Many methods produce excellent estimates of the value of the integral

I =

Ω

f (x)dx

when f is a smooth function of a single variable x and Ω is a finite interval [a, b]. For instance, we can partition the interval into small subintervals, construct a polynomial approximation to f in each subinterval by evaluating f at several points in the subinterval, approximate the integral over the subinterval by the integral of the polynomial, and sum these approximate values. If the function is slowly changing over some pieces of Ω, then we can reduce the error in the approximation by taking longer subintervals there and concentrating our work on regions where the function changes more rapidly.

For multidimensional integrals, however, the situation is much less satisfac- tory. The approach that is so successful in one dimension quickly becomes prohibitive. Suppose, for example, that x ∈ R^10 and Ω is the unit hypercube [0, 1] ×... × [0, 1]. Then, as an example, a polynomial of degree 2 in each variable would have terms of the form

x[] 1 x[] 2 x[] 3 x[] 4 x[] 5 x[] 6 x[] 7 x[] 8 x[] 9 x[] 10

where the number in each box is 0, 1, or 2. So the polynomial has 3^10 = 59, 049 coefficients, and we would need 59,049 function values to determine these. If we partition the domain by dividing each interval [0, 1] into 5 pieces, we make 510 ≈ 10 million boxes, and we would need 59,049 function evaluations in each. Clearly, this method is expensive!

On the other hand, evaluating integrals this way is quite easy to program if we have a function quad that works for functions of a single variable, perhaps using a polynomial approximation method. Then we can use quad to compute

∫ (^1)

0

h(x 1 ) dx 1 ,

where

h(z) =

0

0

f (z, x 2 ,... , x 10 ) dx 2... dx 10 ,

as long as we can evaluate h(z) for any given value z ∈ [0, 1]. But h(z) is just an integration, so we can evaluate it using quad, too. We end up with 10 nested calls to quad. Again, this is very expensive but quite convenient!

As an alternative, some functions f (x) can be well approximated by a separable function f (x) ≈ f 1 (x 1 )f 2 (x 2 )... f 10 (x 10 ).

In that case we can approximate our integral by

I ≈

0

f 1 (x 1 ) dx 1...

0

f 10 (x 10 ) dx 10

the volume of Ω to 1, then for large n, the quantity

n/σ times the errors has a normal distribution (with mean 0, variance 1), where

σ^2 =

∫^1

Ω dx

Ω

(f − I)^2 dx.

Note that the variance is a constant that depends on the variation in f around its average value, but not on the dimension d of the integration domain Ω.

We illustrate Methods 1 and 2 in Figure 1.

Let’s see how well Method 2 behaves on a sample problem, finding the area of the quarter circle illustrated in Figure 1. But keep in mind that these methods are valuable for very high dimensional integrals, not the trivial one that we use in Problem 1.

Problem 1. Suppose we want to estimate the area of a quarter circle with radius r: I =

∫ (^) r

0

r^2 − x^2 dx =

∫ (^) r

0

f (x) dx.

Let r = 0.5 and use Method 2, computing the average value of f (x) and multiplying by r, the length of Ω = [0, r]. Compare the quality of the estimates for 10, 100, 1000, 10000, and 100000 points by measuring the error and the convergence rate. How many function evaluations does your favorite integration routine use to get an estimate of comparable quality?

Importance Sampling

The expected value of our estimate from either of the two methods is equal to the value we are looking for. But there is a non-zero variance to our estimate; we aren’t likely to get the exact value of the integral. Most of the time, though, the value will be close, if n is big enough.

If we could reduce the variance of our estimate, then we could get by with a smaller n. This would mean less work and can be accomplished by importance sampling.

Suppose that we want to estimate

I =

Ω

f (x) dx

where Ω is a region in R^10 with volume equal to one. Our Monte Carlo estimate of this integral involves taking uniformly distributed samples from Ω and taking the average value of f (x) at these samples. We can improve on this by a good choice of a function p(x) satisfying p(x) > 0 for all x ∈ Ω, normalized so that (^) ∫

Ω

p(x) = 1.

Then

I =

Ω

f (x) p(x)

p(x) dx

We can get a Monte Carlo estimate of this integral by taking samples from the distribution with probability density p(x) and taking the average value of f (x)/p(x) at these samples, and we call this Method 3.

When will Method 3 be better than Method 2?

Recall that the variance of our estimate is proportional to

σ^2 =

Ω

f (x) p(x)

− I

p(x) dx.

So if we chose p so that f (x)/p(x) is close to constant, then σ would be close to zero! (For this to be true, it is desirable that f (x) does not change sign on Ω.)

Intuitively, why does importance sampling work?

  • In regions where f (x) is big, p(x) will also be big, so there is a high probability that we will sample from these regions.
  • In regions where f (x) is small, the p(x) will also be small, so we won’t waste time sampling from regions that don’t contribute much to the integral.

We illustrate this in Figure 1.

The big unanswered question is how to get a good choice for p(x). If f is nonnegative, then this can be done by sampling f (x) at a few points and setting p to be piecewise constant, with value proportional to the sampled values. For our unit hypercube example, we could divide our domain into 310 smaller cubes of size 1/3 on which p will be constant. If we evaluate our function f at the center of each of these, this gives a grid of 3^10 values at meshpoints wi with each component of wi equal to 1/6, 1/2, or 5/6. We set p(x) in each cube to be the sampled value f at the center of the cube, divided by the sum of the sampled values. Then for our integration, among our n random values, we could take the number of values in the ith cube to be np(wi).

Let’s repeat our experiment using importance sampling.

Problem 2. Compute new estimates of the integral of Problem 1 using Method 3, taking 10 samples of f (x) to determine the function p(x). Compare with your previous results.

Using quasi-random numbers

There are many uses of random numbers, and the properties that we need from them depend on the ultimate use that we intend. For example, simulation might require that the numbers be as independent of each other as possible, but in Monte-Carlo integration, we just want the proportion of points in any region to be proportional to the volume of that region. This property is actually better achieved by points that are correlated, and there have been many proposals for

Figure 1: Estimating the area 0.19636 of a quarter circle using Monte Carlo methods with 20 function evaluations. Method 1 gives 13 of the 20 green stars inside the circle, for an estimate of 0.163. Method 2 averages the 20 blue function values to give a somewhat better estimate, 0.174. Method 3 averages function values corresponding to the red x’s to yield 0.192.

Problem 6. Use your favorite 1-D integration routine to estimate the partition function Zd(L). When you need a function value ρ(a, a, L), use Monte Carlo inte- gration to obtain it. Try n = 100, 1000 , 10000 , 100000 , 1000000 (if possible) and d = 1, 2 , 4 , 8 , 16. If you don’t do Problem 5, use [-3,3] as the limits of integration in each dimension.

Partition and Conquer

We noted earlier that if the function to be integrated is separable, then we can reduce our problem to a product of 1-dimensional integrations. Although our partition function cannot be separated into d + 1 factors, it can be partially separated by noticing that each variable xi appears only in a pair of functions g, so it makes sense to accumulate

ˆg(xi− 1 , xi+1) =

−∞

g(xi− 1 , xi, L)g(xi, xi+1, L)dxi

for even values of i. If we repeat this trick on ˆg for values of i that are multiples of 4, we have reduced our problem further, and continuing, we can actually reduce the problem to a 2-dimensional integration when d is a power of 2. This very nice observation is due to Nauenberg, Kuttner, and Furman. Therefore, although the partition function provides a nice test problem for multidimensional integration, we should really compute it using this divide- and-conquer formulation.