I would like to perform Taylor expansion of functions

$$f:\mathbb{R}^n \rightarrow \mathbb{R}^n$$

I was wondering how I can force Mathematica to handle the non-commutativity of the resulting tensor products. Following is an example:

Suppose $x, \delta \in \mathbb{R}^n; h \in \mathbb{R}$

$$f(x+h\delta) = f(x) + h f'(x)\delta+ \frac{h^2}{2} f''(x) \,\,\,(\delta, \delta)\quad ...$$

In the above expansion, $f'(x)$ is the Jacobian acting on $\delta$; $f''(x)$ is a 3-tensor acting on the vectors $\delta$ and $\delta$.

  • $\begingroup$ What are non-commutative tensor products you talking about? $\endgroup$ – yarchik Apr 3 '17 at 14:06
  • 2
    $\begingroup$ I think he means products between tensors $\delta $ of different orders. $\endgroup$ – Mirko Aveta Apr 3 '17 at 14:40
  • $\begingroup$ You have to specify $f$, $x$, and $\delta$ as Arrays with the correct dimensions to let Series know the structure. It won't deduce it on its own for arbitrary symbolic objects. $\endgroup$ – Jens Apr 3 '17 at 16:50
  • $\begingroup$ @Jens Can you show me a quick example? $\endgroup$ – mod0 Apr 3 '17 at 18:11

Although I don't know for sure if a solution with explicitly specified dimensions is what you're looking for, here is a way to get the results in that case:

δ = Array["δ", 3];
x = Array["x", 3];
f = Table["f"[i] @@ ##, {i, 3}] &;



The components of the vectors are labeled by integers, e.g., f[1] is the first component of the function f, and it depends on the argument x which has 3 components itself. To distinguish component names from the variables containing the vectors, I use Strings "x", "f". You could also choose completely different names, but strings are nice if you don't plan to assign values to the symbolic components.

With these definitions for the variable x, offset δ and function f as 3-vectors, we can now do the Taylor expansion. To collect the desired tensors, I first get the SeriesCoefficient for each order n (here from 0 to 2). That's a 3-vector. Then do the n-th vectorial derivative of that coefficient vector with D[..., {δ, n}]. See also my answer here. This notation causes D to return the tensor of the correct rank, as you can see from the output of Dimensions:

tensors = 
  Table[D[SeriesCoefficient[f[x + h δ], {h, 0, n}], {δ, n}], {n, 0, 2}];

Map[Dimensions, tensors]


To verify that this is indeed the correct set of tensors, let's see if the formula in the question is reproduced to the order I have chosen here (2):

 Normal[Series[f[x + h δ], {h, 0, 2}]] == 
  tensors[[1]] + h tensors[[2]].δ + h^2/2 tensors[[3]].δ.δ]


|improve this answer|||||
  • $\begingroup$ Thanks! I have accepted your answer. I will see if I can make this work with my needs $\endgroup$ – mod0 Apr 4 '17 at 17:23

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