Application Center - Maplesoft

App Preview:

Line integrals

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Sec18.2LineIntegrals.mws

>

Computing Line Integrals

Worksheet by Mike May, S.J.- maymk@slu.edu

Section 18.2

> restart:

Chapter 18 deals with line integrals. It seems worthwhile to go through using Maple to set up and evaluate line integrals over a parameterized curve. We will walk through a step by step procedure, then procude new procedures that do everything in one command.

A step by step example

First we need to define a vector field that we want to integrate, the parameterized path we are integrating over, and the limits on the parameter. For our example we will use the familiar circular vector field and integrate over half an ellipse.

> vfield := [-y,x];
path := [3*cos(2*t), 2*sin(2*t)];
trange := t=0..Pi/2;

vfield := [-y, x]

path := [3*cos(2*t), 2*sin(2*t)]

trange := t = 0 .. 1/2*Pi

The process of integrating the line integral over the parameterized curve can be broken into 6 steps:

1) Plot a graph of the vector field and the parameterized curve.

2) Set up the line integral with the integrand being the dot product of the vector field and the derivative of the parameterized path.

3) Substitute the parameterization of the path into the field to make the field a vector valued function of the parameter.

4) Take the derivative of the path with respect to the parameter.

5) Evaluate the dot product and simplify. This reduces the problem to an integral over an interval.

6) Evaluate the integral.

We are ready to walk through the steps one at a time. As we work through the example with Maple, you should make sure that you can also do each step by hand.

The first step is to look at a graph of the vector field and the parameterized curve.

> vfieldplot := plots[fieldplot](vfield,x=-5..5,y=-5..5, grid=[7,7]):
parampath := plot([op(path),trange]):
plots[display]({vfieldplot, parampath});

[Maple Plot]

The next step is to set up the line integral

> Int((vfield*Diff(path,t)), trange);

Int([-y, x]*Diff([3*cos(2*t), 2*sin(2*t)],t),t = 0 ...

The third step is to replace x and y and the vector field with the parameterizations of x and y at the appropriate point on the path.

> paramfield := [subs(x=path[1],y=path[2], vfield[1]),
subs(x=path[1],y=path[2], vfield[2])]:
print(`the funtion on the path is `, paramfield);
print(Int((paramfield*Diff(path,t)), trange));

`the funtion on the path is `, [-2*sin(2*t), 3*cos(...

Int([-2*sin(2*t), 3*cos(2*t)]*Diff([3*cos(2*t), 2*s...

The fourth step is to take the derivative of the parameterized path.

> dpath := diff(path, t):
print(`the derivative of the path is `, diff(path, t));
print(Int((paramfield*dpath), trange));

`the derivative of the path is `, [-6*sin(2*t), 4*c...

Int([-2*sin(2*t), 3*cos(2*t)]*[-6*sin(2*t), 4*cos(2...

The fifth step is to evaluate the dot product in the integrand and simplify.

> integrand := simplify(linalg[dotprod](paramfield, dpath, orthogonal)):
print(`The integrand is `, integrand);
print(Int(integrand, trange));

`The integrand is `, 12

Int(12,t = 0 .. 1/2*Pi)

Which we now evaluate the integral and evaluate the result numerically if needed.

> intval := int(integrand, trange);
evalf(intval);

intval := 6*Pi

18.84955592

>

An automated approach

For convenience we block the code into two procedures we can use, one for plotting, and one for setting up the integral and evaluating. This allows us to modify the problem with a minimal amount of work.

> pathplot := proc(vecfield, path, trange, xrange, yrange)
local vfieldplot, parampath;
vfieldplot := plots[fieldplot](vecfield,xrange,yrange, grid=[7,7]):
parampath := plot([op(path),trange]):
plots[display]({vfieldplot, parampath});
end:
lineintegral:= proc(vecfield, path, trange)
local intval, paramfield, dpath, integrand;
print(`the vector field is `, vecfield);
print(`the path is `, path, ` with `, trange);
print(Int((vecfield*Diff(path,t)), trange));
paramfield := [subs(x=path[1],y=path[2], vecfield[1]),
subs(x=path[1],y=path[2], vecfield[2])];
print(`the funtion on the path is `, paramfield);
print(Int((paramfield*Diff(path,t)), trange));
dpath := diff(path, t);
print(`the derivative of the path is `, diff(path, t));
print(Int((paramfield*dpath), trange));
integrand := simplify(linalg[dotprod](paramfield, dpath, orthogonal));
print(`The integrand is `, integrand);
print(Int(integrand, trange));
intval := int(integrand, trange);
print(`the integral is `, intval);
print(evalf(intval));
end:

Thus, we can get the results by entering the vectorfield and path and executing the two commands.

> vfield := [-y,x];
path := [1+3*cos(t), -4+2*sin(t)];
trange := t=0..Pi;
pathplot(vfield, path, trange, x=-5..5, y=-5..5);
lineintegral(vfield, path, trange);

vfield := [-y, x]

path := [1+3*cos(t), -4+2*sin(t)]

trange := t = 0 .. Pi

[Maple Plot]

`the vector field is `, [-y, x]

`the path is `, [1+3*cos(t), -4+2*sin(t)], ` with `...

Int([-y, x]*Diff([1+3*cos(t), -4+2*sin(t)],t),t = 0...

`the funtion on the path is `, [4-2*sin(t), 1+3*cos...

Int([4-2*sin(t), 1+3*cos(t)]*Diff([1+3*cos(t), -4+2...

`the derivative of the path is `, [-3*sin(t), 2*cos...

Int([4-2*sin(t), 1+3*cos(t)]*[-3*sin(t), 2*cos(t)],...

`The integrand is `, -12*sin(t)+2*cos(t)+6

Int(-12*sin(t)+2*cos(t)+6,t = 0 .. Pi)

`the integral is `, -24+6*Pi

-5.15044408

>

Line Integrals in 3-D

If the vector field is in three dimensions, we need to slightly modify the lineinegral command. In that case we will not plot the curve.

> lineintegral3d:= proc(vecfield, path, trange)
local intval, paramfield, dpath, integrand;
print(`the vector field `, vecfield);
print(`the path `, path, ` with `, trange);
print(Int((vecfield*Diff(path,t)), trange));
paramfield := [subs(x=path[1],y=path[2],z=path[3], vecfield[1]),
subs(x=path[1],y=path[2],z=path[3], vecfield[2]),
subs(x=path[1],y=path[2],z=path[3], vecfield[3])];
print(`the funtion on the path is `, paramfield);
print(Int((paramfield*Diff(path,t)), trange));
dpath := diff(path, t);
print(`the derivative of the path is `, diff(path, t));
print(Int((paramfield*dpath), trange));
integrand := simplify(linalg[dotprod](paramfield, dpath, orthogonal));
print(`The integrand is `, integrand);
print(Int(integrand, trange));
intval := int(integrand, trange);
print(`the integral is `, intval);
print(evalf(intval));
end:

Using this command we redo example 4 from the book.

> vfield := [x, z, -x*y];
path := [cos(t), sin(t), 2*t];
trange := t=0..3*Pi;
lineintegral3d(vfield, path, trange);

vfield := [x, z, -x*y]

path := [cos(t), sin(t), 2*t]

trange := t = 0 .. 3*Pi

`the vector field `, [x, z, -x*y]

`the path `, [cos(t), sin(t), 2*t], ` with `, t = 0...

Int([x, z, -x*y]*Diff([cos(t), sin(t), 2*t],t),t = ...

`the funtion on the path is `, [cos(t), 2*t, -cos(t...

Int([cos(t), 2*t, -cos(t)*sin(t)]*Diff([cos(t), sin...

`the derivative of the path is `, [-sin(t), cos(t),...

Int([cos(t), 2*t, -cos(t)*sin(t)]*[-sin(t), cos(t),...

`The integrand is `, -3*cos(t)*sin(t)+2*t*cos(t)

Int(-3*cos(t)*sin(t)+2*t*cos(t),t = 0 .. 3*Pi)

`the integral is `, -4

-4.

>

Exercises

1) Evaluate the line integral where F = [ln(y), ln(x)] and C is the curve given parametrically by [2t, t^2] with t=2..4..

>

2) Evaluate the line integral where F = [2y, -sin(y)] and C is the unit circle traced in a counterclockwise directions from the point (1, 0).

>

3) Evaluate the line integral where F = e^x i + e^y j and C is the part of the ellipse x^2 + 4y^2 = 4 from the point (0, 1) to the point (2, 0) in a clockwise direction.

>

4) Evaluate the line integral where F = -y i + x j + 5 k and C is the helix [cos(t), sin(t) t] for t=0..4Pi.

>

>