# Define tensor as a derivative

I have the tensor which is expressed in terms of coordinate vector. I want to define tensor which is the derivative of the former tensor with respect to the coordinate axis: $$X = (x_1, x_2, x_3) \\ TD_{\alpha \beta \gamma} = \frac{\partial T_{\alpha \beta}}{\partial x_\gamma}$$ However, I want to get the result in terms of general expressions of tensors, for example: $$T_{\alpha \beta} = x_\alpha x_\beta \\ TD_{\alpha \beta \gamma} = \delta_{\alpha \gamma} x_\beta + x_\alpha \delta_{\beta \gamma}$$ And also I want if that's possible to evaluate certain components of the tensor at given $$x_\alpha$$ in code.

What I have now in Wolfram Mathematica is the following:

X = {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]};
r := Sqrt[Sum[(X[[i]]^2, {i, 3}]];
T[i_, j_] :=KroneckerDelta[i, j]/r + X[[i]] X[[j]] / r^3
TD[i_, j_, k_] := D[T[i, j], X[[k]]];


However, that does not allow me to see the whole tensor TD. The program evaluates it as zero:

TD[i, j, k]
0


X = Array[Subscript[x, #] &, 3];
T = Outer[Times, X, X];

TD = D[T, {X}];
TD2 = Array[KroneckerDelta[#, #3] Subscript[x, #2] + Subscript[x, #] KroneckerDelta[##2] &, {3, 3, 3}];

TD == TD2

True

• Thanks! How to get tensorial expression for TD? I can only see its components. – Ilya Bryukhanov Dec 13 '18 at 12:46
• @IlyaBryukhanov I think it impossible, just with the original Mathematica, of which I am not 100% sure, however. – Αλέξανδρος Ζεγγ Dec 13 '18 at 13:20
• If you know the package where I can do it, please let me know! – Ilya Bryukhanov Dec 14 '18 at 21:27