Differential Operations on Matrices and Vectors:
Emphasis on Operations in Appendix A.4
 

Differential operations, for the most part function as expected.  For instance, we can take the divergence of the vector field created earlier. 

 

> Typesetting:-delayDotProduct(VectorCalculus:-Del, vVectorField(x, y, z)); 1
 

(Typesetting:-mprintslash)([(diff(vx(x, y, z), x))+(diff(vy(x, y, z), y))+(diff(vz(x, y, z), z))], [(diff(vx(x, y, z), x))+(diff(vy(x, y, z), y))+(diff(vz(x, y, z), z))]) 

 

Note although it is not completely rigorous, we can also take the divergence of a vector, although when this is done, it is actually treated as a vector field.  We will see this below 

 

> Typesetting:-delayDotProduct(VectorCalculus:-Del, v(x, y, z)); 1
 

(Typesetting:-mprintslash)([(diff(vx(x, y, z), x))+(diff(vy(x, y, z), y))+(diff(vz(x, y, z), z))], [(diff(vx(x, y, z), x))+(diff(vy(x, y, z), y))+(diff(vz(x, y, z), z))]) 

 

However, although this looks like it does exactly what we have asked it to do, in reality, this operation does not lend itself to numerical evaluation.  For instance the following evaluates to zero; however, since the functional dependence of v(x,y,z) on x, y, and z is still undetermined, this is not what we want to happen. 

 

> Typesetting:-delayDotProduct(VectorCalculus:-Del, vVectorField(5, 1, 1)); 1
 

0 

 

The same thing occurs when we treat a vector as a vector field 

 

> Typesetting:-delayDotProduct(VectorCalculus:-Del, v(1, 2, 3)); 1
 

0 

 

To overcome this problem, it helps to define another divergence function, making use of the D operator. 

 

> Divergence2 := proc (GivenVector) options operator, arrow; D[1](GivenVector)[1]+D[2](GivenVector)[2]+D[3](GivenVector)[3] end proc; 1
Divergence2 := proc (GivenVector) options operator, arrow; D[1](GivenVector)[1]+D[2](GivenVector)[2]+D[3](GivenVector)[3] end proc; 1
 

(Typesetting:-mprintslash)([Divergence2 := proc (GivenVector) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)((VectorCalculus:-D)[1](GivenVector)[1], (VectorCalculus:-D)[2](GivenV...
(Typesetting:-mprintslash)([Divergence2 := proc (GivenVector) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)((VectorCalculus:-D)[1](GivenVector)[1], (VectorCalculus:-D)[2](GivenV...
(Typesetting:-mprintslash)([Divergence2 := proc (GivenVector) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)((VectorCalculus:-D)[1](GivenVector)[1], (VectorCalculus:-D)[2](GivenV...
(Typesetting:-mprintslash)([Divergence2 := proc (GivenVector) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)((VectorCalculus:-D)[1](GivenVector)[1], (VectorCalculus:-D)[2](GivenV...
(Typesetting:-mprintslash)([Divergence2 := proc (GivenVector) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)((VectorCalculus:-D)[1](GivenVector)[1], (VectorCalculus:-D)[2](GivenV...
 

 

We can check to see that everything is working properly, and indeed it does exactly what we want it to do as per Appendix A.4-6 

 

> Divergence2(v(x, y, z)); 1
 

D[1](vx(x, y, z))+D[2](vy(x, y, z))+D[3](vz(x, y, z)) 

 

Note this is effectively the same thing as using the divergence operator ∇. However, using D allows the resulting functions to actually be evaluated at given values of x,y,z or ρ,θ,ϕ or whatever else a given application may require. 

 

In the same way, the curl operation generally conforms to the specifications of A.4-10, if we ignore the difficulties in numerical evaluation.  Nonetheless, we have to be sure to actually use a vector field.  Use of a vector as the operand will return an error. 

 

> `&x`(VectorCalculus:-Del, v(x, y, z)); 1
 

Error, (in VectorCalculus:-Curl) the input Vector must be a VectorField 

 

Using the vector field, we see the difference, which looks equivalent to A.4-10. 

 

> `&x`(VectorCalculus:-Del, vVectorField(x, y, z)); 1
 

(Typesetting:-mprintslash)([Vector[column]([[(diff(vz(x, y, z), y))-(diff(vy(x, y, z), z))], [(diff(vx(x, y, z), z))-(diff(vz(x, y, z), x))], [(diff(vy(x, y, z), x))-(diff(vx(x, y, z), y))]], [
(Typesetting:-mprintslash)([Vector[column]([[(diff(vz(x, y, z), y))-(diff(vy(x, y, z), z))], [(diff(vx(x, y, z), z))-(diff(vz(x, y, z), x))], [(diff(vy(x, y, z), x))-(diff(vx(x, y, z), y))]], [
 

 

The attempt to calculate the gradient of a vector field (or its Jacobian) does not seem to compare well to A.4-11. 

 

> Typesetting:-delayGradient(vVectorField(x, y, z)); 1
 

Error, (in VectorCalculus:-Gradient) first argument must be of type algebraic 

 

Nonetheless if we use the Jacobian command we can get the desired result as seen in A.4-11. 

 

> Jacobian(vVectorField(x, y, z), [x, y, z]); 1
 

Matrix(%id = 149187144) 

 

The divergence of a matrix does not evaluate. 

 

> Typesetting:-delayGradient(`τMatrix`(x, y, z)); 1
 

Error, (in VectorCalculus:-Gradient) first argument must be of type algebraic