atensor.rlg 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. Sun Jan 3 23:49:10 MET 1999
  2. REDUCE 3.7, 15-Jan-99 ...
  3. 1: 1:
  4. 2: 2: 2: 2: 2: 2: 2: 2: 2:
  5. 3: 3: %*********************************************************************
  6. % ATENSOR TEST RUN.
  7. %
  8. % V.A.Ilyin & A.P.Kryukov
  9. % E-mail: ilyin@theory.npi.msu.su
  10. % kryukov@theory.npi.msu.su
  11. %
  12. % Nucl. Phys. Inst., Moscow State Univ.
  13. % 119899 Moscow, RUSSIA
  14. %*********************************************************************
  15. % First of all we have to load the ATENSOR program using the one of the
  16. % following command:
  17. % 1) in "atensor.red"$ % If we load source code
  18. % 2) load atensor$ % If we load binary (compiled) code.
  19. load atensor;
  20. % To control of total execution time clear timer:
  21. showtime;
  22. Time: 0 ms
  23. % Switch on the switch TIME to control of executing time
  24. % for each statement.
  25. %on time$
  26. % Let us introduce the antisymmetric tensor of the second order.
  27. tensor a2;
  28. % The antisymmetric property can be expressed as:
  29. tsym a2(i,j)+a2(j,i);
  30. % The K-basis that span K subspace is:
  31. kbasis a2;
  32. a2(i,j) + a2(j,i)
  33. 1
  34. % Let us input very simple example:
  35. a2(k,k);
  36. 0
  37. % By the way the next two expressions looks like different ones:
  38. a2(i,j);
  39. a2(i,j)
  40. a2(j,i);
  41. a2(j,i)
  42. % But the difference of them has a correct value:
  43. a2(j,i)-a2(i,j);
  44. 2*a2(j,i)
  45. % Next examples. For this purpose we introduce 3 abstract
  46. % vectors - v1,v2,v3:
  47. tensor v1,v2,v3;
  48. % The following expression equal zero:
  49. a2(i,j)*v1(i)*v1(j);
  50. 0
  51. % It is interest that the result is consequence of the equivalence
  52. % of the name of tensors.
  53. % While the next one - not:
  54. a2(i,j)*v1(i)*v2(j);
  55. a2(i,j)*v1(i)*v2(j)
  56. % Well. Let us introduce the symmetric tensor of the second order.
  57. tensor s2;
  58. tsym s2(i,j)-s2(j,i);
  59. % Their K-basis look like for a2 excepted sign:
  60. kbasis s2;
  61. s2(j,i) + (-1)*s2(i,j)
  62. 1
  63. % Of course the contraction symmetric and antisymmetric tensors
  64. % equal zero:
  65. a2(i,j)*s2(i,j);
  66. 0
  67. % By the way, the next example not so trivial for computer...
  68. a2(i,j)*a2(j,k)*a2(k,i);
  69. 0
  70. % Much more interesting examples we can demonstrate with the
  71. % the tensor higher order. For example full antisymmetric tensor
  72. % of the third order:
  73. tensor a3;
  74. % The antisymmetric property we can introduce through the
  75. % permutation of the two first indices:
  76. tsym a3(i,j,k)+a3(j,i,k);
  77. % And the cyclic permutation all of them:
  78. tsym a3(i,j,k)-a3(j,k,i);
  79. % The K basis of a3 consist of 5 vectors:
  80. kbasis a3;
  81. a3(k,i,j) + a3(j,i,k)
  82. a3(k,j,i) + (-1)*a3(j,i,k)
  83. a3(i,k,j) + (-1)*a3(j,i,k)
  84. a3(i,j,k) + a3(j,i,k)
  85. a3(j,k,i) + a3(j,i,k)
  86. 5
  87. % In the beginning some very simple examples:
  88. a3(i,k,i);
  89. 0
  90. a3(i,j,k)*s2(i,j);
  91. 0
  92. % The full symmetric tensor of the third order may be introduce
  93. % by the similar way:
  94. tensor s3;
  95. tsym s3(i,j,k)-s3(j,i,k);
  96. tsym s3(i,j,k)-s3(j,k,i);
  97. kbasis s3;
  98. s3(k,j,i) + (-1)*s3(i,j,k)
  99. s3(k,i,j) + (-1)*s3(i,j,k)
  100. s3(j,k,i) + (-1)*s3(i,j,k)
  101. s3(j,i,k) + (-1)*s3(i,j,k)
  102. s3(i,k,j) + (-1)*s3(i,j,k)
  103. 5
  104. % The next examples demonstrate some calculation with them:
  105. s3(i,j,k)-s3(i,k,j);
  106. 0
  107. s3(i,j,k)*a2(i,j);
  108. 0
  109. a3(i,j,k)*s2(i,j);
  110. 0
  111. s3(i,j,k)*a3(i,j,k);
  112. 0
  113. % Now we consider very important physical case - Rieman tensor:
  114. tensor ri;
  115. % It has the antisymmetric property with respect to the permutation
  116. % of the first two indices:
  117. tsym ri(i,j,k,l) + ri(j,i,k,l);
  118. % It has the antisymmetric property with respect to the permutation
  119. % of the second two indices:
  120. tsym ri(i,j,k,l) + ri(i,j,l,k);
  121. % And the triple term identity with cyclic permutation the
  122. % third of them:
  123. tsym ri(i,j,k,l) + ri(i,k,l,j) + ri(i,l,j,k);
  124. % The corresponding K basis consist of 22(!) vectors:
  125. kbasis ri;
  126. ri(l,k,i,j) + (-1)*ri(j,i,k,l)
  127. ri(l,k,j,i) + ri(j,i,k,l)
  128. ri(l,i,k,j) + (-1)*ri(j,k,i,l)
  129. ri(l,i,j,k) + ri(j,k,i,l)
  130. ri(l,j,k,i) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  131. ri(l,j,i,k) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  132. ri(k,l,i,j) + ri(j,i,k,l)
  133. ri(k,l,j,i) + (-1)*ri(j,i,k,l)
  134. ri(k,i,l,j) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  135. ri(k,i,j,l) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  136. ri(k,j,l,i) + (-1)*ri(j,k,i,l)
  137. ri(k,j,i,l) + ri(j,k,i,l)
  138. ri(i,l,k,j) + ri(j,k,i,l)
  139. ri(i,l,j,k) + (-1)*ri(j,k,i,l)
  140. ri(i,k,l,j) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  141. ri(i,k,j,l) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  142. ri(i,j,l,k) + (-1)*ri(j,i,k,l)
  143. ri(i,j,k,l) + ri(j,i,k,l)
  144. ri(j,l,k,i) + ri(j,k,i,l) + (-1)*ri(j,i,k,l)
  145. ri(j,l,i,k) + (-1)*ri(j,k,i,l) + ri(j,i,k,l)
  146. ri(j,k,l,i) + ri(j,k,i,l)
  147. ri(j,i,l,k) + ri(j,i,k,l)
  148. 22
  149. % So we get the answer for any expressions with 3 and more terms of
  150. % Rieman tensors with not more then 2 terms. For example:
  151. ri(i,j,k,l)+ri(j,k,l,i)+ri(k,l,i,j)+ri(l,i,j,k);
  152. (-2)*ri(l,j,i,k) + 4*ri(l,i,j,k)
  153. % This three identities leads us to very important symmetry property with
  154. % respect to exchange of pairs indices:
  155. ri(i,j,k,l)-ri(k,l,i,j);
  156. 0
  157. % Let us start with simple example:
  158. ri(m,n,m,n)-ri(m,n,n,m);
  159. 2*ri(m,n,m,n)
  160. % Much more complicated example is:
  161. a2(m,n)*ri(m,n,c,d) + a2(k,l)*ri(c,d,l,k);
  162. 0
  163. % The answer is trivial but not so simple to obtain one.
  164. % The dimension of the full space is 6! = 720.
  165. % The K basis consists of 690 vectors (to reduce output we
  166. % commented the last statement):
  167. %kbasis ri(a2);
  168. % One else nontrivial examples with Riemann tensors:
  169. (ri(i,j,k,l)-ri(i,k,j,l))*a2(i,j);
  170. a2(i,j)*ri(i,j,k,l)
  171. ---------------------
  172. 2
  173. %***************** END OF TEST RUN ************************
  174. % The total execution time is:
  175. showtime;
  176. Time: 57930 ms plus GC time: 1520 ms
  177. $
  178. END$
  179. 4: 4: 4: 4: 4: 4: 4: 4: 4:
  180. Time for test: 59450 ms, plus GC time: 1520 ms
  181. 5: 5:
  182. Quitting
  183. Sun Jan 3 23:50:12 MET 1999