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]]
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.
{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 $\endgroup$ – akater Jun 6 '14 at 20:57D[V[t]/Sqrt[Dot[V[t], V[t]]], t] /. Dot[a_, b_] :> Dot[b, a] /; LeafCount[a] < LeafCount[b]
$\endgroup$ – chris Oct 10 '14 at 18:44