Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way (or a package built for it) can do simple operations with vectors and matricies of arbitrary size, but conforming extents?

For the simplest example to test, given an arbitrary vector $a,z\in R^n$ and $A \in R^{n \times n}$, $\nabla(a \cdot z) = a$ and the jabobian: $\nabla(A \cdot z) = A$, etc.

I tried the obvious (assuming that $z$ was a vector) Grad[a . z, {z}] etc, but it didn't work. I noticed Differentiating with respect to vectors of unspecified length, and Generating a vector of dummy variables but they didn't appear to help - and may be suggesting that it isn't possible...

share|improve this question
You have to use symbolic tensors‌​. – István Zachar Oct 8 '13 at 23:06
Closely related: How to declare a 3D vector variable?. – Artes Oct 8 '13 at 23:54
Tensors and reductions may be overkill, but they sure look like they would work. Are there easy ways to apply differential operators to an expression with tensors, tensor products, etc? (i.e. my gradient operation above). – jlperla Oct 9 '13 at 2:28
If you perform numerical computations you can consider using built-in Experimantal`NumericalFunction for automatic gradients and Jacobians. – Alexey Popkov Apr 15 '14 at 16:01

Your Answer


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

Browse other questions tagged or ask your own question.