Tensor Analysis Author: Harald Höller last modified: 02.12.09 Licence: Creative Commons Lizenz by-nc-sa 3.0 at Levi-Civita Symbol (Ε - Tensor)
2 Tensor_analysis_m6.nb Ε = Ε = Ε = 1 123 231 312 Ε = Ε = Ε = -1 132 213 321 Some useful relations between Ε -tensors and the Kronecker delta Mathematica commands used in the following section In[1]:=? Sum i max Sum f, i, i max evaluates the sum f. Sum f, i, i min, i max starts with i i min. Sum f, i, i min, i max, di uses steps di. Sumexpr, i, i 1, i 2, uses successive values i 1, i 2,. i 1 Sum f, i, i min, i max, j, j min, j max, evaluates the multiple sum i max j max f. i i min j j min In[2]:=? Signature Signaturelist gives the signature of the permutation needed to place the elements of list in canonical order. In[3]:=? KroneckerDelta KroneckerDeltan 1, n 2, gives the Kronecker delta n1 n 2, equal to 1 if all the n i are equal, and 0 otherwise.
Tensor_analysis_m6.nb 3 In[4]:=? Table Tableexpr, i max generates a list of i max copies of expr. Tableexpr, i, i max generates a list of the values of expr when i runs from 1 to i max. Tableexpr, i, i min, i max starts with i i min. Tableexpr, i, i min, i max, di uses steps di. Tableexpr, i, i 1, i 2, uses the successive values i 1, i 2,. Tableexpr, i, i min, i max, j, j min, j max, gives a nested list. The list associated with i is outermost. In[5]:=? MatrixForm MatrixFormlist prints with the elements of list arranged in a regular array. Summation of two Ε - tensors over all indices Ε Ε = 6 ijk ijk In[6]:= SumSignaturei, j, k Signaturei, j, k, i, 3, j, 3, k, 3 Out[6]= 6 Summation of two Ε - tensors over last two indices Ε Ε = 2 ijk ljk il
4 Tensor_analysis_m6.nb In[7]:= TableSumSignaturei, j, k Signaturel, j, k, j, 3, k, 3, i, 3, l, 3 MatrixForm Out[7]//MatrixForm= 2 0 0 0 2 0 0 0 2 Rule of thumb: antisymmetric times symmetric = 0 Ε = 0 ijk ij In[8]:= SumSignaturei, j, k KroneckerDeltai, j, i, 3, j, 3 Out[8]= 0 Contraction of Kronecker delta = 3 ij ij In[9]:= SumKroneckerDeltai, j KroneckerDeltai, j, i, 3, j, 3 Out[9]= 3 Summation of two Kronecker deltas over one index = ij jk ik
Tensor_analysis_m6.nb 5 In[10]:= TableSumKroneckerDeltai, j KroneckerDeltaj, k, j, 3, i, 3, k, 3 MatrixForm Out[10]//MatrixForm= 1 0 0 0 1 0 0 0 1 Differential Operators in General Coordinates Physics is full of differential operators and in many cases, the simple Euclidean vector space won't provide the coordinates of choice. Thus, often we will have to transform into problem-oriented coordinate systems. With the package "VectorAnalysis", Mathematica supports a list of useful tensorial operations, like gradient, divergence, rotation. In the following section we want to work out some applications to special coordinates and once more compare the Mathematica-way with the "classical" approach. In[11]:= Needs"VectorAnalysis`" Nabla-operator in Cartesian coordinates Classical approach The nabla operator is defined as the sum of derivations with respect to the coordinates times the corresponding base vector. In Cartesian coordinates e x, e y, e z In[12]:= e x : 1, 0, 0 e y : 0, 1, 0 e z : 0, 0, 1
6 Tensor_analysis_m6.nb this yields In[15]:= Nabla func, x, y, z Dfuncx, y, z, x e x Dfuncx, y, z, y e y Dfuncx, y, z, z e z Out[15]= func 1,0,0 x, y, z, func 0,1,0 x, y, z, func 0,0,1 x, y, z Example: Scalar function R We want to check the known relation grad r x r and define as a scalar function the lenght of a vector x by r x 2. In[16]:= Rx, y, z : Sqrtx^2 y ^2 z^2 In[17]:= NablaR, x, y, z MatrixForm Out[17]//MatrixForm= x x 2 y 2 z 2 y x 2 y 2 z 2 z x 2 y 2 z 2 The gradient of a scalar is a tensor of rank 1 i.e. a vectorfield.
Tensor_analysis_m6.nb 7 Mathematica command Grad At first we need to define the coordinate system. We need the following commands In[18]:=? SetCoordinates SetCoordinatescoordsys sets the default coordinate system to be coordsys with default variables. SetCoordinatescoordsysc 1, c 2, c 3 sets the default coordinate system to be coordsys with variables c 1, c 2, and c 3. In[19]:=? Cartesian Cartesian represents the Cartesian coordinate system with default variables Xx, Yy and Zz. Cartesianx, y, z represents the Cartesian coordinate system with variables x, y, and z. In[20]:= SetCoordinatesCartesianx, y, z Out[20]= Cartesianx, y, z The Grad command simply confirms the upper result. In[21]:=? Grad Grad f gives the gradient, f, of the scalar function f in the default coordinate system. Grad f, coordsys gives the gradient of f in the coordinate system coordsys.
8 Tensor_analysis_m6.nb In[22]:= GradSqrtx^2 y ^2 z^2 Out[22]= x x 2 y 2 z 2, y x 2 y 2 z 2, z x 2 y 2 z 2 Example: Vector field In[23]:= Px, y, z : x x 2 y 2 z 2, y x 2 y 2 z 2, z x 2 y 2 z 2 In[24]:= NablaP, x, y, z FullSimplify Out[24]= y 2 z 2 x y x z,,, x 2 y 2 z 2 32 x 2 y 2 z 2 32 x 2 y 2 z 2 32 x y, x 2 y 2 z 2 32 x 2 z 2 y z x z y z,,,, x 2 y 2 z 2 32 x 2 y 2 z 2 32 x 2 y 2 z 2 32 x 2 y 2 z 2 32 x 2 y 2 x 2 y 2 z 2 32 The nabla operator applied on a tensor of rank 1 produces a tensor of rank 2. The divergence of our vector field P is given by the trace of the gradient on P. The divergence is of course a scalar again. In[25]:=? Tr Trlist finds the trace of the matrix or tensor list. Trlist, f finds a generalized trace, combining terms with f instead of Plus. Trlist, f, n goes down to level n in list.
Tensor_analysis_m6.nb 9 In[26]:= TrNablaP, x, y, z Out[26]= x 2 x 2 y 2 z 2 32 y 2 x 2 y 2 z 2 32 z 2 x 2 y 2 z 2 32 3 x 2 y 2 z 2 In[27]:= FullSimplify Out[27]= 2 x 2 y 2 z 2 Again we confirm with the Mathematica command (Div). In[28]:=? Div Div f gives the divergence, f, of the vector field f in the default coordinate system. Div f, coordsys gives the divergence of f in the coordinate system coordsys. In[29]:= Div x x 2 y 2 z 2, y x 2 y 2 z 2, z x 2 y 2 z 2 FullSimplify Out[29]= 2 x 2 y 2 z 2
10 Tensor_analysis_m6.nb Nabla Operator in spherical coordinates The Mathematica-way In[30]:= Clear"Global` " In[31]:=? Spherical Spherical represents the spherical coordinate system with default variables Rr, Ttheta and Pphi. Sphericalr, Θ, Φ represents the spherical coordinate system with variables r, Θ and Φ. In[32]:= SetCoordinatesSphericalr, Θ, Φ Out[32]= Sphericalr, Θ, Φ In[33]:= Gradr Out[33]= 1, 0, 0 In[34]:= Div1, 0, 0 Out[34]= 2 r
Tensor_analysis_m6.nb 11 Alternatively Define spherical coordinates by their transformation rules In[35]:= x : r SinΘ CosΦ y : r SinΘ SinΦ z : r CosΘ and determine the Jacobian of the transformation In[38]:= Tij Dx, r, Dx, Θ, Dx, Φ, Dy, r, Dy, Θ, Dy, Φ, Dz, r, Dz, Θ, Dz, Φ Out[38]= CosΦ SinΘ, r CosΘ CosΦ, r SinΘ SinΦ, SinΘ SinΦ, r CosΘ SinΦ, r CosΦ SinΘ, CosΘ, r SinΘ, 0 and determine the base vectors. In[39]:= e r TransposeTij1 e Θ TransposeTij2 e Φ TransposeTij3 Out[39]= CosΦ SinΘ, SinΘ SinΦ, CosΘ Out[40]= r CosΘ CosΦ, r CosΘ SinΦ, r SinΘ Out[41]= r SinΘ SinΦ, r CosΦ SinΘ, 0
12 Tensor_analysis_m6.nb In[42]:= Nablaspher func, r, Θ, Φ Dfuncr, Θ, Φ, r e r Dfuncr, Θ, Φ, Θ e Θ Dfuncr, Θ, Φ, Φ e Φ Out[42]= r SinΘ SinΦ func 0,0,1 r, Θ, Φ r CosΘ CosΦ func 0,1,0 r, Θ, Φ CosΦ SinΘ func 1,0,0 r, Θ, Φ, r CosΦ SinΘ func 0,0,1 r, Θ, Φ r CosΘ SinΦ func 0,1,0 r, Θ, Φ SinΘ SinΦ func 1,0,0 r, Θ, Φ, r SinΘ func 0,1,0 r, Θ, Φ CosΘ func 1,0,0 r, Θ, Φ In[43]:= Assumingr 0, FullSimplifySqrtx^2 y ^2 z^2 Out[43]= r In[44]:= Rspherr, Θ, Φ : r In[45]:= NablaspherRspher, r, Θ, Φ FullSimplify Out[45]= CosΦ SinΘ, SinΘ SinΦ, CosΘ The same result looks quite different than the constant vector {1,0,0} from the Mathematica-way. However, the result is in perfect agreement, since it is only a different way of expressing the unit vector in r-direction. In[46]:= e r Out[46]= True