Maths - Tensor Programs

There are a number of open source programs that can work with tensors. I have used Axiom, how to install Axiom here.

I have put user input in red:

(1) -> CT := CARTEN(i0 := 1, 2,Integer)
           (1)  CartesianTensor(1,2,Integer)
           Type: Domain

(2) -> t0: CT := 8
           (2)  8
           Type: CartesianTensor(1,2,Integer)

(3) -> rank t0
 (3)  0
             Type: NonNegativeInteger

(4) -> v: DirectProduct(2, Integer) := directProduct [3,4]
 (4)  [3,4]
             Type: DirectProduct(2,Integer)

(5) -> Tv: CT := v
             +1  2+
        (5)  |    |
             +4  5+
        Type: SquareMatrix(2,Integer)

(6) -> m: SquareMatrix(2, Integer) := matrix[[1,2],[4,5]]
             +1  2+
        (6)  |    |
             +4  5+
        Type: SquareMatrix(2,Integer)

(7) -> Tm: CT := m
             +1  2+
        (7)  |    |
             +4  5+
        Type: CartesianTensor(1,2,Integer)

(8) -> n: SquareMatrix(2, Integer) := matrix[[2,3],[0,1]]
             +2  3+
        (8)  |    |
             +0  1+
        Type: SquareMatrix(2,Integer)

(9) -> Tn: CT := n
             +2  3+
        (9)  |    |
             +0  1+
        Type: CartesianTensor(1,2,Integer)
 
(10) -> t1: CT := [2,3]
             (10)  [2,3]
        Type: CartesianTensor(1,2,Integer)

(11) -> rank t1
             (11)  1
        Type: PositiveInteger

(12) -> t2: CT := [t1,t1]
             +2  3+
       (12)  |    |
             +2  3+
       Type: CartesianTensor(1,2,Integer)

(13) -> t3: CT := [t2,t2]
             +2  3+ +2  3+
      (13)  [|    |,|    |]
             +2  3+ +2  3+
       Type: CartesianTensor(1,2,Integer)

(14) -> tt: CT := [t3,t3]; tt := [tt,tt]
             ++2  3+  +2  3++ ++2  3+  +2  3++
             ||    |  |    || ||    |  |    ||
             |+2  3+  +2  3+| |+2  3+  +2  3+|
      (14)  [|              |,|              |]
             |+2  3+  +2  3+| |+2  3+  +2  3+|
             ||    |  |    || ||    |  |    ||
             ++2  3+  +2  3++ ++2  3+  +2  3++
       Type: CartesianTensor(1,2,Integer)
 
(15) -> rank tt
 (15)  5
         Type: PositiveInteger

(16) -> Tmn := product(Tm,Tn)
             ++2  3+    +4  6+ +
             ||    |    |    | |
             |+0  1+    +0  2+ |
       (16)  |                 |
             |+8  12+  +10  15+|
             ||     |  |      ||
             ++0  4 +  +0   5 ++
         Type: CartesianTensor(1,2,Integer)

(17) -> Tmv := contract(Tm,2,Tv,1)
 >> Error detected within library code:
             Improper index for contraction
(17) -> Tm*Tv
             +Tv   2Tv+
       (17)  |        |
             +4Tv  5Tv+
       Type: CartesianTensor(1,2,Polynomial Integer)

(18) -> Tmv = m * v
 (18)  [Tmv,Tmv]= [11,32]
             Type: Equation DirectProduct(2,Polynomial Integer)

(19) -> t0()
 (19)  8
             Type: PositiveInteger

(20) -> t1(1+1)
 (20)  3
             Type: PositiveInteger

(21) -> t2(2,1)
 (21)  2
             Type: PositiveInteger

(22) -> t3(2,1,2)
 (22)  3
             Type: PositiveInteger

(23) -> Tmn(2,1,2,1)
 (23)  0
             Type: NonNegativeInteger

(24) -> t0[]
 (24)  8
             Type: PositiveInteger

(25) -> t1[2]
 (25)  3
             Type: PositiveInteger

(26) -> t2[2,1]
 (26)  2
             Type: PositiveInteger

(27) -> t3[2,1,2]
 (27)  3
             Type: PositiveInteger

(28) -> Tmn[2,1,2,1]
 (28)  0
             Type: NonNegativeInteger

(29) -> cTmn := contract(Tmn,1,2)
             +12  18+
       (29)  |      |
             +0   6 +
        Type: CartesianTensor(1,2,Integer)

(30) -> trace(m) * n
             +12  18+
       (30)  |      |
             +0   6 +
       Type: SquareMatrix(2,Integer)

(31) -> contract(Tmn,1,2) = trace(m) * n
             +12  18+  +12  18+
       (31)  |      |= |      |
             +0   6 +  +0   6 +
      Type: Equation CartesianTensor(1,2,Integer)

(32) -> contract(Tmn,1,3) = transpose(m) * n
             +2  7 +  +2  7 +
       (32)  |     |= |     |
             +4  11+  +4  11+
        Type: Equation CartesianTensor(1,2,Integer)

(33) -> contract(Tmn,1,4) = transpose(m) * transpose(n)
             +14  4+  +14  4+
       (33)  |     |= |     |
             +19  5+  +19  5+
       Type: Equation CartesianTensor(1,2,Integer)

(34) -> contract(Tmn,2,3) = m * n
             +2  5 +  +2  5 +
       (34)  |     |= |     |
             +8  17+  +8  17+
       Type: Equation CartesianTensor(1,2,Integer)

(35) -> contract(Tmn,2,4) = m * transpose(n)
             +8   2+  +8   2+
       (35)  |     |= |     |
             +23  5+  +23  5+
       Type: Equation CartesianTensor(1,2,Integer)

(36) -> contract(Tmn,3,4) = trace(n) * m
             +3   6 +  +3   6 +
       (36)  |      |= |      |
             +12  15+  +12  15+
       Type: Equation CartesianTensor(1,2,Integer)

(37) -> tTmn := transpose(Tmn,1,3)
             ++2  3 +  +4   6 ++
             ||     |  |      ||
             |+8  12+  +10  15+|
       (37)  |                 |
             |+0  1+    +0  2+ |
             ||    |    |    | |
             ++0  4+    +0  5+ +
       Type: CartesianTensor(1,2,Integer)

(38) -> transpose Tmn
             ++2  8+   +4  10++
             ||    |   |     ||
             |+0  0+   +0  0 +|
       (38)  |                |
             |+3  12+  +6  15+|
             ||     |  |     ||
             ++1  4 +  +2  5 ++
       Type: CartesianTensor(1,2,Integer)

(39) -> transpose Tm=transpose m
             +1  4+  +1  4+
       (39)  |    |= |    |
             +2  5+  +2  5+
       Type: Equation CartesianTensor(1,2,Integer)

(40) -> rTmn := reindex(Tmn,[1,4,2,3])
             ++2  0+   +3  1+ +
             ||    |   |    | |
             |+4  0+   +6  2+ |
       (40)  |                |
             |+8   0+  +12  4+|
             ||     |  |     ||
             ++10  0+  +15  5++
       Type: CartesianTensor(1,2,Integer)

(41) -> tt:=transpose(Tm)*Tn - Tn*transpose(Tm)
             +- 6  - 16+
       (41)  |         |
             + 2    6  +
       Type: CartesianTensor(1,2,Integer)

(42) -> Tv*(tt+Tn)
             +- 4Tv  - 13Tv+
       (42)  |             |
             + 2Tv    7Tv  +
        Type: CartesianTensor(1,2,Polynomial Integer)

(43) -> reindex(product(Tn,Tn),[4,3,2,1])+3*Tn*product(Tm,Tm)
             ++46   84 +  +57   114++
             ||        |  |        ||
             |+174  212+  +228  285+|
       (43)  |                      |
             | +18  24+    +17  30+ |
             | |      |    |      | |
             + +57  63+    +63  76+ +
        Type: CartesianTensor(1,2,Integer)

(44) -> delta: CT := kroneckerDelta()
             +1  0+
       (44)  |    |
             +0  1+
        Type: CartesianTensor(1,2,Integer)

(45) -> contract(Tmn, 2, delta, 1) =reindex(Tmn,[1,3,4,2])
             + +2  4+   +0  0++  + +2  4+   +0  0++
             | |    |   |    ||  | |    |   |    ||
             | +3  6+   +1  2+|  | +3  6+   +1  2+|
       (45)  |                |= |                |
             |+8   10+  +0  0+|  |+8   10+  +0  0+|
             ||      |  |    ||  ||      |  |    ||
             ++12  15+  +4  5++  ++12  15+  +4  5++
        Type: Equation CartesianTensor(1,2,Integer)

(46) -> epsilon:CT := leviCivitaSymbol()
             + 0   1+
       (46)  |      |
             +- 1  0+
       Type: CartesianTensor(1,2,Integer)

(47) -> contract(epsilon*Tm*epsilon,1,2) = 2 * determinant m
 (47)  - 6= - 6
             Type: Equation CartesianTensor(1,2,Integer)

metadata block
see also:

 

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

flag flag flag flag flag flag The Princeton Companion to Mathematics - This is a big book that attempts to give a wide overview of the whole of mathematics, inevitably there are many things missing, but it gives a good insight into the history, concepts, branches, theorems and wider perspective of mathematics. It is well written and, if you are interested in maths, this is the type of book where you can open a page at random and find something interesting to read. To some extent it can be used as a reference book, although it doesn't have tables of formula for trig functions and so on, but where it is most useful is when you want to read about various topics to find out which topics are interesting and relevant to you.

 

Terminology and Notation

Specific to this page here:

 

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2023 Martin John Baker - All rights reserved - privacy policy.