# Axiom/FriCAS Clifford Algebra - Associative Tests

Here are some tests to make sure that the code is Associative:

## Results

Check for associativity:

```(1) -> Pf := PrimeField(17)

(1)  PrimeField(17)
Type: Domain
(2) -> bL := matrix([[1,1],[0,1]])\$SquareMatrix(2,PrimeField(17))

+1  1+
(2)  |    |
+0  1+
Type: SquareMatrix(2,PrimeField(17))
(3) -> Ca := CliffordAlgebra(2,Pf,bL)

(3)  CliffordAlgebra(2,PrimeField(17),[[1,1],[0,1]])
Type: Domain
(4) -> randc() == reduce('+, [random()\$Pf*eFromBinaryMap(i)\$Ca for i in 0..3])
Type: Void
(5) -> a := randc()
Compiling function randc with type () -> CliffordAlgebra(2,
PrimeField(17),[[1,1],[0,1]])

(5)  10 + 3e  + e  + 4e e
1    2     1 2
Type: CliffordAlgebra(2,PrimeField(17),[[1,1],[0,1]])
(6) -> b := randc()

(6)  15 + 2e  + 16e  + 2e e
1      2     1 2
Type: CliffordAlgebra(2,PrimeField(17),[[1,1],[0,1]])
(7) -> c := randc()

(7)  12 + 6e  + 9e e
1     1 2
Type: CliffordAlgebra(2,PrimeField(17),[[1,1],[0,1]])
(8) -> (a*b)*c - a*(b*c)

(8)  0
Type: CliffordAlgebra(2,PrimeField(17),[[1,1],[0,1]])
```

## Results 2

compare different methods for orthogonal case:

```(3) -> Pf := PrimeField(17)

(3)  PrimeField(17)
Type: Domain
(4) -> bL := matrix([[1, 1, 0], [1, 1, 1], [0, 1, 1]])\$SquareMatrix(3, PrimeField(17))

+1  1  0+
|       |
(4)  |1  1  1|
|       |
+0  1  1+
Type: SquareMatrix(3,PrimeField(17))
(5) -> Ca := CliffordAlgebra(3, Pf, bL)

(5)  CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
Type: Domain
(6) -> randc() == reduce('+, [random()\$Pf*eFromBinaryMap(i)\$Ca for i in 0..7])
Type: Void
(7) -> a := randc()
Compiling function randc with type () -> CliffordAlgebra(3,
PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])

(7)  10 + 3e  + e  + 4e e  + 15e  + 2e e  + 16e e  + 2e e e
1    2     1 2      3     1 3      2 3     1 2 3
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(8) -> b := randc()

(8)  12 + 6e  + 9e e  + 9e  + 10e e  + 4e e
1     1 2     3      1 3     2 3
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(9) -> c := randc()

(9)  4 + 3e  + 10e  + 2e e  + 2e  + 11e e  + 7e e  + 16e e e
1      2     1 2     3      1 3     2 3      1 2 3
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(10) -> (a*b)*c - a*(b*c)

(10)  0
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(11) -> a := randc()

(11)  14 + 11e  + 13e  + 12e e  + 16e  + 8e e  + 5e e  + 8e e e
1      2      1 2      3     1 3     2 3     1 2 3
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(12) -> b := randc()

(12)  10 + 4e  + 10e  + 11e e  + 8e  + 15e e  + 14e e  + 6e e e
1      2      1 2     3      1 3      2 3     1 2 3
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(13) -> c := randc()

(13)  15 + 2e  + 5e  + 4e e  + 15e  + 13e e  + 5e e  + 16e e e
1     2     1 2      3      1 3     2 3      1 2 3
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(14) -> (a*b)*c - a*(b*c)

(14)  0
Type: CliffordAlgebra(3,PrimeField(17),[[1,1,0],[1,1,1],[0,1,1]])
(15) -> B1 := CliffordAlgebra(3,Fraction(Integer),[[1,0,0],[0,1,0],[0,0,1]])

(15)  CliffordAlgebra(3,Fraction(Integer),[[1,0,0],[0,1,0],[0,0,1]])
Type: Domain
(16) -> m1 := toTable(*)\$B1

+  1       e        e       e e      e       e e      e e    e e e +
|           1        2       1 2      3       1 3      2 3    1 2 3|
|                                                                  |
|  e       1       e e       e      e e       e      e e e    e e  |
|   1               1 2       2      1 3       3      1 2 3    2 3 |
|                                                                  |
|  e     - e e      1       - e     e e    - e e e     e     - e e |
|   2       1 2                1     2 3      1 2 3     3       1 3|
|                                                                  |
| e e     - e       e       - 1    e e e    - e e     e e     - e  |
|  1 2       2       1              1 2 3      2 3     1 3       3 |
(16)  |                                                                  |
|  e     - e e    - e e    e e e     1       - e      - e     e e  |
|   3       1 3      2 3    1 2 3               1        2     1 2 |
|                                                                  |
| e e     - e    - e e e    e e      e       - 1     - e e     e   |
|  1 3       3      1 2 3    2 3      1                 1 2     2  |
|                                                                  |
| e e    e e e     - e     - e e     e       e e      - 1     - e  |
|  2 3    1 2 3       3       1 3     2       1 2                1 |
|                                                                  |
|e e e    e e     - e e     - e     e e       e       - e     - 1  |
+ 1 2 3    2 3       1 3       3     1 2       2         1         +
Type: Matrix(CliffordAlgebra(3,Fraction(Integer),[[1,0,0],[0,1,0],[0,0,1]]))
(17) -> setMode("orthogonal",false)\$B1

(17)  true
Type: Boolean
(18) -> m1 - toTable(*)\$B1

+0  0  0  0  0  0  0  0+
|                      |
|0  0  0  0  0  0  0  0|
|                      |
|0  0  0  0  0  0  0  0|
|                      |
|0  0  0  0  0  0  0  0|
(18)  |                      |
|0  0  0  0  0  0  0  0|
|                      |
|0  0  0  0  0  0  0  0|
|                      |
|0  0  0  0  0  0  0  0|
|                      |
+0  0  0  0  0  0  0  0+
Type: Matrix(CliffordAlgebra(3,Fraction(Integer),[[1,0,0],[0,1,0],[0,0,1]]))
(19) -> setMode("debug",true)\$B1

(19)  true
Type: Boolean
(20) -> toTable(*)\$B1
cliffordProdTerm: e12*e12=e1*-e1-0*e12=-11
cliffordProdTerm: e12*e13=e1*-e123-0*e13=-e23
cliffordProdTerm: e12*e23=e1*e3-0*e23=e13
cliffordProdTerm: e12*e123=e1*-e13-0*e123=-e3
cliffordProdTerm: e13*e12=e1*e123-0*e12=e23
cliffordProdTerm: e13*e13=e1*-e1-0*e13=-11
cliffordProdTerm: e13*e23=e1*-e2-0*e23=-e12
cliffordProdTerm: e13*e123=e1*e12-0*e123=e2
cliffordProdTerm: e23*e12=e2*e123-0*e12=-e13
cliffordProdTerm: e23*e13=e2*-e1-0*e13=e12
cliffordProdTerm: e23*e23=e2*-e2-0*e23=-11
cliffordProdTerm: e23*e123=e2*e12-0*e123=-e1
rcProdTerm: e12Le1= e1L-e1/\e2+0=-e2
rcProdTerm: e12Le2= e1L-e2/\e2+e1=e1
rcProdTerm: e12Le3= e1L-e3/\e2+0=0
cliffordProdTerm: e12*e123=e1*-e13-0*e123=-e3
cliffordProdTerm: e123*e12=e12*e123-0*e12=-e3
rcProdTerm: e12Le3= e1L-e3/\e2+0=0
rcProdTerm: e12Le3= e1L-e3/\e2+0=0
cliffordProdTerm: e123*e13=e12*-e1-0*e13=e2
rcProdTerm: e12Le3= e1L-e3/\e2+0=0
cliffordProdTerm: e123*e23=e12*-e2-0*e23=-e1
rcProdTerm: e12Le3= e1L-e3/\e2+0=0
cliffordProdTerm: e12*e12=e1*-e1-0*e12=-11
cliffordProdTerm: e123*e123=e12*e12-0*e123=-11

+  1       e        e       e e      e       e e      e e    e e e +
|           1        2       1 2      3       1 3      2 3    1 2 3|
|                                                                  |
|  e       1       e e       e      e e       e      e e e    e e  |
|   1               1 2       2      1 3       3      1 2 3    2 3 |
|                                                                  |
|  e     - e e      1       - e     e e    - e e e     e     - e e |
|   2       1 2                1     2 3      1 2 3     3       1 3|
|                                                                  |
| e e     - e       e       - 1    e e e    - e e     e e     - e  |
|  1 2       2       1              1 2 3      2 3     1 3       3 |
(20)  |                                                                  |
|  e     - e e    - e e    e e e     1       - e      - e     e e  |
|   3       1 3      2 3    1 2 3               1        2     1 2 |
|                                                                  |
| e e     - e    - e e e    e e      e       - 1     - e e     e   |
|  1 3       3      1 2 3    2 3      1                 1 2     2  |
|                                                                  |
| e e    e e e     - e     - e e     e       e e      - 1     - e  |
|  2 3    1 2 3       3       1 3     2       1 2                1 |
|                                                                  |
|e e e    e e     - e e     - e     e e       e       - e     - 1  |
+ 1 2 3    2 3       1 3       3     1 2       2         1         +
Type: Matrix(CliffordAlgebra(3,Fraction(Integer),[[1,0,0],[0,1,0],[0,0,1]]))
(21) ->
```