2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – bbgodfrey May 9 '15 at 20:18
  • 1
    $\begingroup$ 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? $\endgroup$ – bbgodfrey May 9 '15 at 20:23
  • $\begingroup$ 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$? $\endgroup$ – J. M. will be back soon May 9 '15 at 20:40
  • $\begingroup$ @Guesswhoitis. you are correct, that was a typo. $\endgroup$ – Yair Daon May 9 '15 at 20:55
  • $\begingroup$ @bbgodfrey precisely. This is just a composition. $\endgroup$ – Yair Daon May 9 '15 at 20:56
1
$\begingroup$

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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