Calculus IV with Maple
Copyright 2002, Dr. Jack Wagner
j.wagner@intelligentsearch.com
Lesson 2: Vector Derivatives: grad, div, curl, laplacian
Topics : Gradient, divergence, curl are illustrated and graphically interpreted. Laplacian defined.
Maple commands introduced:
Gradient, Divergence, Curl, Laplacian, fieldplot, evalVF
Gradient
Example 2.1
Let
. Compute and plot grad w. We will plot level sets
(
k
) , for k from 0.1 to 1.0.
| > | restart: with(plots): with(LinearAlgebra): with(VectorCalculus): |
| > | f := sin(x) - log(sin(y)); |
Plotting ten level sets of f(x, y)
| > | S := seq(f - 1/k = 0, k = 1..10): |
| > | P1 := implicitplot({S}, x = 3..3.5, y = 0..1.5, numpoints = 1000): |
| > | display(P1, scaling = constrained); |
The value of k represented by these curves increases from right to left.
Now compute the gradient at x = 3.3 on the level set of
| > | gf := Gradient(f - 1/10, [x, y]); |
| > | Y := fsolve(subs(x = 3.3, f - 1/10), y); |
| > | G := evalVF(gf, <3.3, Y>); |
evalVF
Now we draw and plot a line through the point [3.3, .8832282346], and parallel to G.
| > | N := <3.3, Y> + s * G; |
| > | P2 := plot([N[1], N[2], s = - 0.2..0.3], thickness = 2, color = black): |
| > | display(P1, P2, scaling = constrained); |
The gradient vector appears to pierce each of the level sets orthogonally to its tangent. If this is so, then the gradient vector represents the shortest distance between successive level sets and, therefore, the most rapid change in the value of w. This is, in fact, true of any function in any dimension.
We consider a surface of arbitrary dimension represented by a level set of a map: F:
->
R
;
f
(
...
) =
K
, and a curve,
, imbedded in the surface, and passing through a point,
.
=
K
Taking the gradient:
= grad F(
'(
t
) = 0. Since
is the principal part of the tangent vector to
, grad
F
(
(
t
)) is orthogonal to the tangent to the curve
at p. But every tangent to the surface at p, is the tangent to a curve, (existence theorem for solution of first order differential equations) so grad
F
(
(
t
)) is orthogonal to the tangent plane at p. The gradient vector represents the direction and magnitude of the greatest change in F, at the point where it is evaluated.
This can be illustrated easily in three dimensions.
Example 2.2
Let
. Compute and plot the gradient vector.
Define an implicit function of (x, y, z) for various values of K.
| > | restart: with(plots): with(LinearAlgebra):with(VectorCalculus): with(plottools): |
| > | F := K ->z - x^2 + y^2 + 4 * x * y - K: |
| > | v := [x, y, z]: gradF := Gradient(F(0), v); |
We could equally well have taken any value of K. 0 happens to be convenient because it gives simple integer values for the components of the gradient.
| > | p := <1, 1, - 4>: |
| > | gF[1, 1, - 4] := evalVF(gradF, p); #The gradient vector at (1, 1, - 4) |
| > | G := p + s * gF[1, 1, - 4]; |
| > | P1 := spacecurve(evalm(G), s = - .2..0.25, color = black, thickness = 2, axes = boxed): |
| > | S := seq(implicitplot3d(F(5 * k), x = 0..2, y = 0..2, z = - 5.. - 2, style = wireframe, color = pink, grid = [12, 12, 12]), k = 0..3): |
| > | display(S, P1, scaling = constrained, orientation = [ - 20, 65]); |
The gradient vector appears to be orthogonal to each of the level sets.
Without presenting any mathematical justification (although ample justification exists), we will operate with the gradient vector operator as if it were an ordinary vector; we will take both the dot product and the crossproduct of del with ordinary vectors and with itself.
The curl of a vector V is defined by: curl(V) = del x V
| > | restart: with(LinearAlgebra): with(VectorCalculus):with(linalg): |
There are two defined forms of the curl in Maple. One, spelled with a small "c" is in the linalg package and operates on vectors; the other, spelled with a capital "C" is in the VectorCalculus package and operates on vector fields.
curl
Curl
| > | V := VectorField(<v[1](x, y, z), v[2](x, y, z), v[3](x, y, z)>, 'cartesian'[x, y, z]); |
| > | Curl(V); |
| > | V1 := [v[1](x, y, z), v[2](x, y, z), v[3](x, y, z)];r := [x, y, z]: |
| > | curl(V1, r); |
To have an idea of what this means, consider a vector field, that is, a function that assigns a vector to each point in the domain.
Example 2.3
Let
Take the curl of this vector field and fieldplot both.
fieldplot fieldplot3d
| > | restart: with(LinearAlgebra): with(VectorCalculus):with(linalg):with(plots): |
| > | F := (x, y) -><x^2 * y, y^2 * x, x^2 - y^2>: |
| > | F(x, y); |
| > | curl_F := curl(F(x, y), [x, y, z]); |
| > | f1 := fieldplot3d(F(x, y), x = - 10..10, y = - 10..10, z = - 10..10, axes = framed, color = red, arrows = THICK, grid = [3, 3, 3]): |
| > | f2 := fieldplot3d(curl_F, x = - 10..10, y = - 10..10, z = - 10..10, axes = framed, color = black, arrows = THICK, grid = [3, 3, 3]): |
| > | display(f1, f2); |
If the original vector field F, (thick arrows) represents the velocity of fluid flow in a container, then curl F (the thinner arrows) is the torque exerted by the fluid, both in magnitude and direction, (determined by the right hand rule). If any group of thick vectors is rotated into an adjacent group and the fingers of the right hand curled in the direction of rotation, the thumb of the right hand will point in the direction of the thinner vectors (the torque) situated between the two groups.
Now formally defining the vector field.
| > | FF := VectorField(F(x, y), 'cartesian'[x, y, z]); |
| > | CFF := Curl(FF); |
| > | P3 := fieldplot3d(FF, x = - 10..10, y = - 10..10, z = - 10..10, axes = framed, color = red, arrows = THICK, grid = [3, 3, 3]): |
| > | P4 := fieldplot3d(CFF, x = - 10..10, y = - 10..10, z = - 10..10, axes = framed, color = black, arrows = THICK, grid = [3, 3, 3]): |
| > | display(P3, P4); |
The alternative to Curl .
| > | Del &x FF; |
Note that, because of the equality of mixed partial derivatives, del x del = 0.
| > | del := <d/dx, d/dy, d/dz>; |
| > | del &x del; |
Since we are considering del as a vector we may also take the dot product of del with a vector, V. This is known as the divergence of V. Again there are two definitions, Divergence and diverge in the VectorCalculus and linalg packages, operating on vector fields and vectors respectively.
Divergence
diverge
| > | restart: with(linalg): with(LinearAlgebra): with(VectorCalculus): with(plots): |
| > | V := (x, y, z) -> <v[1](x, y, z), v[2](x, y, z), v[3](x, y, z)>: |
| > | VV := VectorField(V(x, y, z), 'cartesian'[x, y, z]); |
| > | Divergence(VV); |
| > | V1 := [v[1](x, y, z), v[2](x, y, z), v[3](x, y, z)]; |
| > | diverge(V1, [x, y, z]); |
To have a picture of what this might mean, suppose we consider F as the velocity field of some gas. That is, F is a vector field representing the velocity of the gas particles (assumed to be uniform) at each point.
Example 2.4
Find and plot the divergence of
.
| > | restart: with(plots): with(LinearAlgebra): with(VectorCalculus): |
| > | F := (x, y) ->[x^2 * y, y^2 * x, x^2 - y^2]: |
| > | FF := VectorField(<F(x, y)>, 'cartesian'[x, y, z]); |
| > | Div_F := Divergence(FF); |
The divergence is a scalar quantity. If we construct a vector parametrized by x and y with div_F as the z coordinate, we will obtain a surface representing div F at each point in the x - y plane.
| > | G := <x, y, 4 * x * y>; |
We now plot G together with F.
| > | P1 := plot3d(G, x = - 2..2, y = - 2..2, axes = framed, color = blue, style = wireframe): |
| > | P2 := fieldplot3d(F(x, y), x = - 2..2, y = - 2..2, z = - 2..2, axes = framed, color = pink, color = red, arrows = THICK, grid = [5, 5, 2]): |
| > | display(P1, P2); |
The surface div V represents the flux of gas out of a unit cube. Observe that where the arrows point inward, the flux is negative, gas particles accumulate in the cube; the density of the gas rises. Where the arrows point outward, the flux is positive, the density of gas particles in the cube is diminishing. div F therefore measures the change in density of gas in the cube.
div(grad) is defined and is an operator of the greatest importance: the Laplacian.
Maple does not have a way to input partial differential operators.
| > | del := <d/dx, d/dy, d/dz>; |
| > | Lap := del.del; |
The Laplacian function, is however, defined in the linalg package and the VectorCalculus package.
laplacian
Laplacian
Grad, curl and div figure largely in physical applications and will all be looked at more closely as we proceed.
Practice
1. Plot each of the following vector fields together with its curl.
a.
b.
c.