Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.3K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Compute the gradient of a function of vectors

Posted 2 years ago

I want to compute the gradient of a function of vectors.

$Assumptions = (u | v | w) \[Element] Vectors[3, Reals];
D[u. v, {u}]

but I can't make Mathematica output the (obvious) correct answer, "v". All I can get is either that the symbolic gradient or 1.v

Can other maths packages do this?

POSTED BY: Alexander Heger
5 Replies

In the Wikipedia page on matrix calculus there is a long list of identities, including the one you need. I suppose they can be implemented in the Wolfram Language with some attention.

POSTED BY: Gianluca Gorni

There is the Grad, that does what you want, but returns an output open to interpretation.

Grad[ (3 u). v,u]
3 1.v 

Grad is defined to work on explicit lists with some obvoius rules of linearity.

So you can simply unprotect Dot and define

Dot[  x_?NumericQ, v_ ] := x v 
Dot[ v_, x_?NumericQ ] := x v 

Generally, multi-linear functions like Dot should be augmented by rules for Simplify in the case of inert, empty and numerical arguments. Physicists have no problem to interpret 1 and 0 as diagonal nxn matrices, for the dimension n, that the Dot product can insert at the current position without changing the result.

Here the number 1 is the abstract unit matrix of the dimension of v , as the unit matrices and their multiples are isomorphic to the field of scalars by actionon vectors and matrices.

Roland Franzius

POSTED BY: Roland Franzius

Hi, Alexander.

The Vectors is usually used when tensors calculations rather than vector analysis, as far as I know.

If you want to calculate directional derivative of a function along a vector. Here is a way to do that.

Set vectors components manually, then do the calculations as above. Both D and Grad result the same - {v1, v2, v3}, which is exactly vecv (vector v).

Hope this is helpful.

POSTED BY: Bowen Ping

Dear Bowen,

thanks for the example!

Yes, symbolic tensor calculations is more what I had in mind. In my case, I only go to order 2, so all could be nicely written in terms of vectors, matrices, and inner and outer (for the vectors) products, and cross products. Since the expressions are long, it would be a nightmare - and error-prone - to reconstruct them from the components. I also don't need to worry about covariant or contravariant indices. Such vector/matrix expressions seem to me very common in the literature. Again, thanks for trying to help, much appreciated.

-Alexander

POSTED BY: Alexander Heger

I am afraid Mathematica is not designed to handle that kind of symbolic differentiation, at the moment. I doubt that it could be done using the same D function without breaking important functionality. There may be external packages for symbolic vector calculus, somebody else may know about them.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard