Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I often need to compute derivatives or integrals involving N-dimensional vectors (where the dimension could be equal to 2 or 3 but is not particularly relevant for the sake of the derivation). The only way I know to translate this into valid Mathematica input is to specialize to a particular N and define all quantities component-wise.

A simple example: computing the time derivative of a normalized quantity

V[t_] := {x[t], y[t], z[t]}
Simplify[D[V[t]/Sqrt[Dot[V[t], V[t]]], t]]

Time derivative of a normalized quantity

While correct, this can obviously get extremely messy fast. At that point, I find it easier to just do the computation by hand using generic vector calculus identities which work for vectors of any dimension.

I was wondering if there is a way of doing such computations using an abstract vector type? This post references a Vectors command that is potentially related, but it was not clear to me how to use it for calculus.

Edit: After some more experimentation with Vectors, I was able to get quite close to what I was looking for:

$Assumptions = V[t] \[Element] Vectors[3, Reals];
Simplify[D[V[t]/Sqrt[Dot[V[t], V[t]]], t]]

$$\frac{2 V(t).V(t) V'(t)-V(t) \left(V(t).V'(t)+V'(t).V(t)\right)}{2 (V(t).V(t))^{3/2}}$$

However, neither Simplify[] nor TensorReduce[] could simplify the commutative dot product in the expression above.

share|improve this question
2  
There may be different levels of “abstract” in “abstract vectors”. I'd say they are not “abstract” if kept in coordinate-based form {x@t, y@t, z@t}. Things will probably always get messy unless you use coordinate-free approach, or at least abstract indices. en.wikipedia.org/wiki/Abstract_index_notation To my knowledge, there is no Mathematica package for the latter (definitely no built-in support); as to the former, you might be interested in this: wolfram.com/products/applications/atlas2 –  Akater Jun 6 at 20:57
    
Plus, post code, not images as it is easier to experiment with it. –  Sektor Jun 6 at 21:07
1  
Take a look here How to declare a 3D vector variable? –  Artes Jun 6 at 21:13
    
@Artes: I have updated my question. –  Wenzel Jakob Jun 6 at 22:14
    
How about D[V[t]/Sqrt[Dot[V[t], V[t]]], t] /. Dot[a_, b_] :> Dot[b, a] /; LeafCount[a] < LeafCount[b] –  chris Oct 10 at 18:44

1 Answer 1

It seems the simplest way to simplify such expression is to impose sorting based on CountLeaf

D[V[t]/Sqrt[Dot[V[t], V[t]]], t] /.   
     Dot[a_, b_] :>  Dot[b, a] /; LeafCount[a] < LeafCount[b]

Mathematica graphics

so that for instance the longest expression is always last. This is not bulletproof but it seems to do the trick on your example(?)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.