# Algebraic Manipulations with Indices

I am absolutely new to Mathematica, but I've heard it is a pretty powerful tool for symbolic calculations.

My problem (stated generally): I have three dimensional array. I define a symbolic operator on it. It is symbolic since it depends on three unspecified arrays $\mathbf u,\mathbf v, \mathbf w$. I want to avoid doing the algebra and let Mathematica find $[\mathbf A^3\mathbf T]_{ijk}$, where $\mathbf{A}^3$ is a composition ($\mathbf{A}$ operating on $\mathbf{T}$ three times). I would really appreciate references.

More concretely, let $\mathbf T \in \mathbb{R}^{n \times n \times n}$. Define a linear operator on it as follows: $$[\mathbf A\mathbf T]_{ijk} = u_{(i+1)jk}(T_{(i+1)jk} +T_{ijk}) - u_{ijk}(T_{ijk} +T_{(i-1)jk}) \\ + v_{i(j+1)k}(T_{i(j+1)k} +T_{ijk}) - v_{ijk}(T_{ijk} +T_{i(j-1)k}) \\ + w_{ij(k+1)}(T_{ij(k+1)} +T_{ijk}) - w_{ijk}(T_{ijk} +T_{ij(k-1)})$$

I use a periodic boundary, so every index is really $\bmod n$, but it doesn't really matter in this context.

I want to find $[\mathbf A^2\mathbf T]_{ijk}$ and $[\mathbf A^3\mathbf T]_{ijk}$.

I searched (not too thoroughly, though) in the documentation and cannot find anything to help in this context.

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey May 9 '15 at 20:18
• I expect that many readers will have difficulty understanding your question. For instance, is A the matrix operator that produces the expression on the right of your equation, and is A^n meant to be a power of the matrix? – bbgodfrey May 9 '15 at 20:23
• Looks like $A$ itself is supposed to be a rank-$3$ tensor with periodic indices. Altho… why does the $w$ factor in the fifth term only have two indices instead of $3$? – J. M. will be back soon May 9 '15 at 20:40
• @Guesswhoitis. you are correct, that was a typo. – Yair Daon May 9 '15 at 20:55
• @bbgodfrey precisely. This is just a composition. – Yair Daon May 9 '15 at 20:56

Here is a simple solution. Think of everything as functions. Then define:

A = Function[T , Function[{i,j,k}, u[i+1,j,k]*(T[i+1,j,k]+T[i,j,k]) -
u[i-1,j,k]*(T[i-1,j,k]+T[i,j,k]) +
v[i,j+1,k]*(T[i,j+1,k]+T[i,j,k]) -
v[i,j-1,k]*(T[i,j-1,k]+T[i,j,k]) +
...
]]


Then the evaluations

A[A[T]][i,j,k]
A[A[A[T]]][i,j,k]


give $[A^2T]_{ijk}$ and $[A^3T]_{ijk}$.

Neat, huh? Bottom line: think of arrays as functions and use your $\lambda$ calculus.

• Composition[] ought to be helpful in this situation. – J. M. will be back soon May 10 '15 at 0:23
• @Guesswhoitis. neat, thanks!! – Yair Daon May 10 '15 at 0:34
• One could now do something like Operate[Composition @@ ConstantArray[A, n], T[i, j, k]] for general powers. – J. M. will be back soon May 10 '15 at 0:57
• Nice solution, but two typos should be fixed: comma before first u, and last u replaced by v. – bbgodfrey May 10 '15 at 5:59
• @bbgodfrey fixed. – Yair Daon May 11 '15 at 19:19