]> 25.4 Numerical Evaluation of Line Integrals

25.4 Numerical Evaluation of Line Integrals

Suppose we confront a line integral, which is an integral along a path in some Euclidean space, of a vector field v · d s

C v · d s

We can set up a spreadsheet to evaluate such an integral with very little difficulty.

In this section we describe how this can be done, and attempt to goad you into doing one yourself on a spreadsheet.

By the way, once you have such a thing, you can modify the path or the integrand or your grid size with a tiny amount of effort, and so can use your product to evaluate any line integral you ever encounter.

A line integral is more complicated than an ordinary integral primarily in that you have to deal with a path as well as an integrand, while for an ordinary integrand the path is an interval of the real line which is completely characterized by two numbers, its endpoints, and you need only deal with the integrand.

What we do depends on how the path C on which the integral is to be evaluated is defined.

The easiest case, which we address here, occurs when we are given C as a parametrized curve.

This means that we have a parameter, let us call it t , and have formulae for each coordinate, x , y , z , , as functions of t , and an interval of t values defines the curve.

Our plan is to break up the t interval into many small pieces, and at the boundaries of these pieces calculate x ( t ) , y ( t ) , z ( t ) , and v x ( x ( t ) , y ( t ) , ) , v y ( x ( t ) , y ( t ) , ) ,

In words, we will devote a column to the calculation of each of x , y and z (in three dimensions); and to each component of the vector field v , evaluated at ( x ( t ) , y ( t ) , z ( t ) ) . Then we use a column to describe the contribution to the integral from one subinterval, say between t and t + d .

And what do we use to estimate that contribution?

t is the change in x ( t ) over that interval multiplied by the average value of v x over the endpoints of the interval plus the same thing in y and in z . We write down only the x contribution here, which is

( x ( t + d ) x ( t ) ) v x ( x ( t + d ) , y ( t + d ) , z ( t + d ) ) + v x ( x ( t ) , y ( t ) , z ( t ) ) 2

In the last column we add up these contributions over the various intervals, and that is our integral. This is the trapezoid rule for line integrals.

Once this is done, how do we change the path? Alter the x ( t ) , y ( t ) and z ( t ) columns to use different functions of t .

How do we change the integrand, v ? Change its columns.

How do we change the interval size parameter d ? Just change it.

Exactly how do we do this?

I like to leave the top five or so rows for notes and data entry.

In B2 I would put the starting t value and in B3 the value for d .

In the top row I would give a verbal description of the curve and vector field.

So I would start the computation in row 6.

Here is what I would put in the t column, column A

A6=B2

A7=A6+B3

A8=2*A7-A6

And I would copy A8 down the sheet into A9-A1005. (or further if you like)

In the x , y and z columns put

B6=x(A6) (you must put in what this function is of course)

C6= y(A6)

D6=z(A6)

And copy these down to B7-B1005, etc.

In the v columns put the values for the components of v

E 6 = v x ( B 6 , C 6 , D 6 )

F 6 = v y ( B 6 , C 6 , D 6 )

G 6 = v z ( B 6 , C 6 , D 6 )

And copy these down.

Next set

H6=(B7-B6)*(E(7)+E(6))/2

And copy this into the I6 and J6 places, and down the sheet.

Set

K6=H6+I6+J6

And

L7=L6+K6

And copy these down, and you are done.

If the final t value occurs in Ak, then the integrand answer will be in Lk.

You can adjust d and can extrapolate exactly as for ordinary integrals.

The method used here is the path integral version of the trapezoid rule.

With a little guile you can extrapolate this to get a path integral version of Simpson's rule, and extrapolate that as well.

You can check on accuracy by doing the integral for one d value and for 2 d and 4 d as well (make sure you adjust the endpoint suitably, to check on your accuracy).

Without extrapolation the differences in answers should go down by a factor of 4 when you decrease d by a factor of two; taking 4 3 of the finer result less 1 3 or the coarser one should improve the result to Simpson.

And so on.