My question is really easy for experienced users. In my tensor equations I have an unknown tensor Q (symmetric and traceless):
$Q=\begin{pmatrix} n1(x,y) & n2(x,y) \\ n2(x,y) & -n1(x,y) \end{pmatrix}$
In mathematica:
Q = {{n1[x, y, t], n2[x, y, t]}, {n2[x, y, t], -n1[x, y, t]}}
I need to calculate and work with the following tensors:
1) $P1_{\alpha\beta}=(\partial_\alpha Q_{\gamma\epsilon})(\partial_\beta Q_{\gamma\epsilon})=\sum_{\gamma,\epsilon} \left[\frac{\partial Q_{\gamma\epsilon}}{\partial x_\alpha} \frac{\partial Q_{\gamma\epsilon}}{\partial x_\beta}\right]$
2) $P2_{\alpha\beta}=(\partial_\gamma Q_{\gamma\epsilon})(\partial_\epsilon Q_{\alpha\beta})=\sum_{\gamma,\epsilon} \left[\frac{\partial Q_{\gamma\epsilon}}{\partial x_\gamma} \frac{\partial Q_{\alpha\beta}}{\partial x_\epsilon}\right]$
3) $P3_{\alpha\beta}=Q_{\gamma\epsilon}(\partial_{\epsilon\gamma} Q_{\alpha\beta})=\sum_{\gamma,\epsilon} \left[Q_{\gamma\epsilon} \frac{\partial^2 Q_{\alpha\beta}}{\partial x_\gamma \partial x_\epsilon}\right]$
Where Einstein summation rule is used, all indexes are either 1 or 2 (x or y)., $\partial_{\epsilon\gamma}$ is second derivative over $x_\gamma$ and $x_\epsilon$.
I figured how to calculate $P2$,since $P2=(\nabla\cdot Q)\cdot(\nabla Q)$, an inner product of divergence by gradient. In mathematica, since indexes are messed, you have to multiply gradient by divergence:
r = {x, y}
Simplify[D[Q, {r}].Div[Q,r]]
I checked analytically that this result is correct.
I have no idea how to calculate $P1, P3$.
The best answer would be the code, which finds the required tensors by definition, i.e. by direct summations of products of certain entries.
table
andsum
commands. I don't have much experience with this stuff $\endgroup$