3

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$.

mod0
  • 45
  • 4

1 Answers1

3

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}] &;

f[x]

f

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]

$\{\{3\},\{3,3\},\{3,3,3\}\}$

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):

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

True

Jens
  • 97,245
  • 7
  • 213
  • 499
  • Thanks! I have accepted your answer. I will see if I can make this work with my needs – mod0 Apr 04 '17 at 17:23