Line Integrals and Conservative Vector Fields

copyright © 2009 by Jonathan Rosenberg based on an earlier M-book, copyright © 2000 by Paul Green and Jonathan Rosenberg

Contents

In this lesson, we will evaluate integrals of the form

$$ \int_C\overrightarrow F \cdot \overrightarrow T\,ds,$$

where C is a curve directed by a choice of forward unit tangent vector T, and F is a vector field defined in a vicinity of C. The key observation is that if r(t) parametrizes C in such a way that the forward direction corresponds to increasing t, then we have the identity

$$ \overrightarrow T\,ds = \frac{d\overrightarrow r}{dt}\,dt, $$

so that the integral takes the form

$$ \int_{t_0}^{t_1} \overrightarrow F( \overrightarrow r(t))\cdot \frac{d\overrightarrow r}{dt}\,dt$$

where t0 and t1 are the initial and terminal values of the parameter t. It is important to understand that the parametrization r(t) and the vector field F are independent of one another except for the requirement that the composition F(r(t)) must make sense for all relevant values of t. Note also that all of this makes equally good sense in the plane, where F and r each have two components, and in 3-space, where each has three components.

syms x y z t
realdot = @(u, v) u*transpose(v);

Example 1

Let us integrate the vector field

F = [y^2,sqrt(4-z^2),x]
 
F =
 
[ y^2, (4 - z^2)^(1/2), x]
 

along the twisted cubic parametrized and directed by

tcube = [t,t^2,t^3]
 
tcube =
 
[ t, t^2, t^3]
 

for t between 0 and 1. We must express F in terms of the parameter:

Fpar = subs(F,[x,y,z],tcube)
 
Fpar =
 
[ t^4, (4 - t^6)^(1/2), t]
 

Now we set

integrand = realdot(Fpar,diff(tcube,t))
 
integrand =
 
2*t*(4 - t^6)^(1/2) + 3*t^3 + t^4
 

This integral cannot be evaluated symbolically, so we evaluate it numerically in two different ways.

integral=double(int(integrand,t,0,1))
alternate=quadl(@(t) eval(vectorize(integrand)),0,1)
Warning: Explicit integral could not be found. 

integral =

    2.8850


alternate =

    2.8850

Problem 1

Integrate the vector field

G=[2*y,-3*x]
 
G =
 
[ 2*y, (-3)*x]
 

around the unit circle in the xy-plane, directed counterclockwise.

Example 2

We proceed now to illustrate the Fundamental Theorem of Line Integrals, which states that if F is the gradient of a function f, and C is a directed curve originating at A and terminating at B, then

$$\int_C \overrightarrow F \cdot \overrightarrow T\,ds = f(B) - f(A). $$

Let us set

f = x*y + cos(y*z) + exp(x*z)
H = jacobian(f,[x,y,z])
 
f =
 
cos(y*z) + exp(x*z) + x*y
 
 
H =
 
[ y + z*exp(x*z), x - z*sin(y*z), x*exp(x*z) - y*sin(y*z)]
 

and evaluate along the twisted cubic in two different ways.

Hpar = subs(H,[x,y,z],tcube)
integrand = realdot(Hpar,diff(tcube,t))
ans1 = int(integrand,t,0,1)
A = subs(tcube,t,0)
B = subs(tcube,t,1)
ans2 = subs(f,[x,y,z],B) - subs(f,[x,y,z],A)
double(ans1-ans2)
 
Hpar =
 
[ t^3*exp(t^4) + t^2, t - t^3*sin(t^5), t*exp(t^4) - t^2*sin(t^5)]
 
 
integrand =
 
3*t^2*(t*exp(t^4) - t^2*sin(t^5)) + 2*t*(t - t^3*sin(t^5)) + t^3*exp(t^4) + t^2
 
 
ans1 =
 
cos(1) + exp(1) - 1
 

A =

     0     0     0


B =

     1     1     1


ans2 =

    2.2586


ans =

  9.6955e-017

The difference here can be attributed to round-off error.

Problem 2

Evaluate

$$ \int_C \overrightarrow\nabla g \cdot \overrightarrow T \, ds$$

two different ways as in Example 2, where

g=sqrt(5+x^2+2*y^2+3*z^2)
 
g =
 
(x^2 + 2*y^2 + 3*z^2 + 5)^(1/2)
 

and C is the directed line segment from [1,3,4] to [0,-3,8].

In connection with the fundamental theorem of line integrals, it is of interest to be able to recognize when a vector field is a gradient and to recover a function of which it is a gradient. A vector field is called conservative (the term has nothing to do with politics, but comes from the notion of "conservation laws" in physics) if its line integral over every closed curve is 0, or equivalently, if it is the gradient of a function. We recall that the curl of a gradient is always 0, and that a vector field whose curl is 0 is, at least locally, a gradient. To compute the curl, you can use http://www.math.umd.edu/users/jmr/241/mfiles/curl.m.

Note that this is quite different from the built-in MATLAB function curl, which won't help you much.

Example 3

As an example, we consider the vector field

F3 = [2*x*(9+y^2-4*z^2)/(-9+x^2+y^2+z^2)^2, ...
    -2*y*(-18+x^2+5*z^2)/(-9+x^2+y^2+z^2)^2, ...
    2*z*(-27+4*x^2+5*y^2)/(-9+x^2+y^2+z^2)^2]
simplify(curl(F3,[x,y,z]))
 
F3 =
 
[ (2*x*(y^2 - 4*z^2 + 9))/(x^2 + y^2 + z^2 - 9)^2, -(2*y*(x^2 + 5*z^2 - 18))/(x^2 + y^2 + z^2 - 9)^2, (2*z*(4*x^2 + 5*y^2 - 27))/(x^2 + y^2 + z^2 - 9)^2]
 
 
ans =
 
[ 0, 0, 0]
 

We see that the curl of F3 is 0, and that F3 is defined everywhere except on the sphere

$$ x^2+y^2+z^2 = 9. $$

Given any point pt inside the sphere, we can integrate F3 along the directed line segment from a reference point (in this case, the origin 0) to the given point, and that should recover a function whose gradient is F3. Let us try it.

pt = [x,y,z];
seg = t*pt;
F3par = subs(F3,pt,seg)
integrand=realdot(F3par,diff(seg,t))
f3 = int(integrand,t,0,1)
simplify(jacobian(f3,[x,y,z])-F3)
 
F3par =
 
[ (2*t*x*(t^2*y^2 - 4*t^2*z^2 + 9))/(t^2*x^2 + t^2*y^2 + t^2*z^2 - 9)^2, -(2*t*y*(t^2*x^2 + 5*t^2*z^2 - 18))/(t^2*x^2 + t^2*y^2 + t^2*z^2 - 9)^2, (2*t*z*(4*t^2*x^2 + 5*t^2*y^2 - 27))/(t^2*x^2 + t^2*y^2 + t^2*z^2 - 9)^2]
 
 
integrand =
 
(2*t*x^2*(t^2*y^2 - 4*t^2*z^2 + 9))/(t^2*x^2 + t^2*y^2 + t^2*z^2 - 9)^2 - (2*t*y^2*(t^2*x^2 + 5*t^2*z^2 - 18))/(t^2*x^2 + t^2*y^2 + t^2*z^2 - 9)^2 + (2*t*z^2*(4*t^2*x^2 + 5*t^2*y^2 - 27))/(t^2*x^2 + t^2*y^2 + t^2*z^2 - 9)^2
 
 
f3 =
 
- (y^2 - 4*z^2 + 9)/(x^2 + y^2 + z^2 - 9) - 1
 
 
ans =
 
[ 0, 0, 0]
 

Problem 3

Show that there is a function, defined for positive x, y, and z, whose gradient is G3, as defined in the following cell. Find such a function and check your answer. Because G3 is not defined at the origin, you will need to change your reference point to some point with positive coordinates such as [1,1,1]. How will this affect the analogue of seg in Example 3?

G3=[2/x, -2/(y^2+z^2)*y, -2/(y^2+z^2)*z]
 
G3 =
 
[ 2/x, -(2*y)/(y^2 + z^2), -(2*z)/(y^2 + z^2)]
 

Caution: Sometimes integrating along rays is not the best way to find a function whose gradient is a given conservative vector field. The problem is that sometimes the line integral will be too complicated to evaluate, while one can still find the function by "integrating one variable at a time".

Example 4

As an example, we consider the vector field

F4 =[-2*sin(x^2*y)*x*y*exp(z)+3/(1+z^4), -sin(x^2*y)*x^2*exp(z)-2*y/(1+z^4), ...
    cos(x^2*y)*exp(z)-4*(3*x-y^2)/(1+z^4)^2*z^3]
 
F4 =
 
[ 3/(z^4 + 1) - 2*x*y*sin(x^2*y)*exp(z), - (2*y)/(z^4 + 1) - x^2*sin(x^2*y)*exp(z), cos(x^2*y)*exp(z) - (z^3*(12*x - 4*y^2))/(z^4 + 1)^2]
 

This vector field is conservative, since it is everywhere defined and

simplify(curl(F4,[x,y,z]))
 
ans =
 
[ 0, 0, 0]
 

However, integrating F4 along rays starting from the origin is not the best way to find a function f of which F4 is the gradient. Instead, we try to solve the equations

$$\frac{\partial f}{\partial x} = \overrightarrow{F4}(1), \quad \frac{\partial f}{\partial y} = \overrightarrow{F4}(2), \quad \frac{\partial f}{\partial z} = \overrightarrow{F4}(3), $$

one at a time. Since the y-dependence is the simplest, it's easiest to begin with the middle equation and let

f1=int(F4(2),y)
 
f1 =
 
cos(x^2*y)*exp(z) - y^2/(z^4 + 1)
 

Then if we take

simplify(F4-jacobian(f1,[x,y,z]))
 
ans =
 
[ 3/(z^4 + 1), 0, -(12*x*z^3)/(z^4 + 1)^2]
 

we're reduced to a much simpler vector field, and if

f2=int(ans(1),x)
 
f2 =
 
(3*x)/(z^4 + 1)
 

then

simplify(F4-jacobian(f1+f2,[x,y,z]))
 
ans =
 
[ 0, 0, 0]
 

shows F4 is the gradient of:

f = simple(f1+f2)
 
f =
 
cos(x^2*y)*exp(z) + (3*x - y^2)/(z^4 + 1)
 

Check:

simplify(F4 - jacobian(f, [x,y,z]))
 
ans =
 
[ 0, 0, 0]
 

Additional Problems:

1. Let F be as in Example 1. Evaluate

$$  \int_C\overrightarrow F \cdot \overrightarrow T\,ds,$$

along the directed line segment from [0,0,0] to [1,1,1]. Do you expect the same answer as in Example 1? What does this have to do with curl(F) ?

2. Find a function whose gradient is H2, defined below. Check your answer.

H2 = [4*x/(1+2*x^2+3*y^2+z^4), 6*y/(1+2*x^2+3*y^2+z^4), 4*z^3/(1+2*x^2+3*y^2+z^4)]
 
H2 =
 
[ (4*x)/(2*x^2 + 3*y^2 + z^4 + 1), (6*y)/(2*x^2 + 3*y^2 + z^4 + 1), (4*z^3)/(2*x^2 + 3*y^2 + z^4 + 1)]
 

3. Evaluate

$$  \int_C\overrightarrow{H2}\cdot \overrightarrow T\,ds,$$

both directly and using the results of Additional Problem 2, where C is the elliptical spiral parametrized below, and t runs from 0 to 2*pi.

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