MultiVariate Directional Derivative

None of these suggestions allow for the evaluation of the directional derivative at a particular point, in this case (1, -2, 3). (I cannot make the command line suggestion work at all - error: "expects its 2nd argument, v, to be of type ('Vector')(algebraic), but received [x, y, z]")

Surely, evaluation can be done without an additional substitution statement.

John Vawter

Directional derivatives

Try this:

restart;
VectorCalculus[DirectionalDiff](x*exp(y)/(3*z^2+1),
<1,-2,3>,[x,y,z]);

However, if you have several directional derivatives to compute you could do this:

restart;
f := (a,b,c)->VectorCalculus[DirectionalDiff](x*exp(y)/(3*z^2+1),<a,b,c> ,[x, y, z] ):
f(1,-2,3);
f(4,-5,6);

Hope this helps,

J. Tarr

MultiVariate Directional Derivative

Thanks, but all these methods give me functions of x, y, z. I wanted the directional derivative evaluated at a particular point with numerical rectangular coordinates, an answer something like 3 or sqrt(5) or Pi.

John Vawter

It depends on the function

The directional derivative will evaluate to a simple numerical answer if the derivatives of the function are constants. For example:

restart;
f := (a,b,c)->VectorCalculus[DirectionalDiff](2*x+3*y+4*z+1,<a,b,c> ,[x, y, z] ):
f(1,-2,3);
f(4,-5,6);

Hope this helps,

J. Tarr

The function?

So, a numerical directional derivative for functions of 3 variables is only obtainable with a hyperplane where the gradient is constant? Giving one variable an exponent of 2 in your example function gives me a directional derivative which is a function of that variable. (Of course, a control-click (right click) allows evaluation at any point.)

John Vawter

Oops

Sorry, I misread your question. The directional derivative can be evaluated at any given point by substituting the value of that point's coordinates in the derivative. For example:

restart; with(VectorCalculus):
sph := (x-a)^2+(y-b)^2+(z-c)^2-r^2;
dd := DirectionalDiff( sph , <v1,v2,v3>, [x,y,z] );
v1,v2,v3 := 1,2,3;
dd;
x,y,z := 4,5,6;
dd;
a,b,c := 0,0,0;
dd;

You can, of course, use eval, or subs, if that is more convenient.

J. Tarr

Oops

Good work, J. Tarr. That does it. I am curious about the way Maple works here. Once the directional derivative is defined, entering a vector, coordinates or other parameters requires that you call the directional derivative function again and presumably update it. I guess there is no way to call the directional derivative function just once (after you have defined a vector and point)? (I did try this and got an "unknown coordinate system: [4, 5, 6]" error.)

Thanks again,
John Vawter

eval

You could do something like this:

restart; with(VectorCalculus):
sph := (x-7)^2+(y-8)^2+(z-9)^2-r^2;
eval(DirectionalDiff( sph , <1,2,3>, [x,y,z] ), {x=4,y=5,z=6});

or a bit more flexibly like this:

restart;
f := (V1,V2,V3,X,Y,Z)->eval(VectorCalculus:-DirectionalDiff(g,<i,j,k> ,[x, y, z] ),{i=V1,j=V2,k=V3,x=X,y=Y,z=Z}):
g := (x-7)^2+(y-8)^2+(z-9)^2-r^2;
ans := f(1,2,3,4,5,6);

Hope this helps,

J. Tarr

eval

Very good, J. Tarr.

John Vawter

Gradient of a vector

Is the DirectionalDiff command the tool I should use to find the gradient of a vector.  MAPLE HELP has a gradient as well as NABLA command but it seems they can only be used on scalar functions to convert them into a gradient vector.  Instead of this I am seeking the gradient of a vector which then yields a 2nd order tensor.  Is there something else I should use?

Doug Meade's picture

VectorCalculus,Jacobian

I think you want to be using the Jacobian command from the VectorCalculus package ( ?VectorCalculus,Jacobian ).

Doug

---------------------------------------------------------------------
Douglas B. Meade  <><
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu

Yep that does the trick

It would seem that the MAPLE help menu would have a link to the Jacobian from the gradient help page.  That would have helped me save some time.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}