====================================================================
CliffordAlgebra examples
====================================================================

CliffordAlgebra(n,K,Q) defines a vector space of dimension 2^n over
the field K with a given quadratic form Q.  If {e1..en} is a basis for
K^n then


{ 1,
  e(i)         1 <= i <= n,
  e(i1)*e(i2)  1 <= i1 < i2 <=n,
  ...,
  e(1)*e(2)*...*e(n) }

is a basis for the Clifford algebra. The algebra is defined by the relations

  e(i)*e(i) = Q(e(i))
  e(i)*e(j) = -e(j)*e(i),  for i ^= j

Examples of Clifford Algebras are gaussians (complex numbers),
quaternions, exterior algebras and spin algebras.

====================================================================
The Complex Numbers as a Clifford Algebra
====================================================================

This is the field over which we will work, rational functions with
integer coefficients.

  K := Fraction Polynomial Integer
   Fraction Polynomial Integer
                         Type: Domain

We use this matrix for the quadratic form.

  m := matrix [ [-1] ]
   [- 1]
                         Type: Matrix Integer

We get complex arithmetic by using this domain.

  C := CliffordAlgebra(1, K, quadraticForm m)
   CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)
                         Type: Domain

Here is i, the usual square root of -1.

  i: C := e(1)
   e
    1
               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)

Here are some examples of the arithmetic.

  x := a + b * i
   a + b e
          1
               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)

  y := c + d * i
   c + d e
          1
               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)

  x * y
   - b d + a c + (a d + b c)e
                             1
               Type: CliffordAlgebra(1,Fraction Polynomial Integer,MATRIX)

====================================================================
The Quaternion Numbers as a Clifford Algebra
====================================================================

This is the field over which we will work, rational functions with
integer coefficients.

  K := Fraction Polynomial Integer
   Fraction Polynomial Integer
                      Type: Domain

We use this matrix for the quadratic form.

  m := matrix [ [-1,0],[0,-1] ]
   +- 1   0 +
   |        |
   + 0   - 1+
                      Type: Matrix Integer

The resulting domain is the quaternions.

  H  := CliffordAlgebra(2, K, quadraticForm m)
   CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)
                      Type: Domain

We use Hamilton's notation for i, j, k.

  i: H  := e(1)
   e
    1
              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

  j: H  := e(2)
   e
    2
              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

  k: H  := i * j
   e e
    1 2
              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

  x := a + b * i + c * j + d * k
   a + b e  + c e  + d e e
          1      2      1 2
              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

  y := e + f * i + g * j + h * k 
   e + f e  + g e  + h e e
          1      2      1 2
              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

  x + y
   e + a + (f + b)e  + (g + c)e  + (h + d)e e
                   1           2           1 2
              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

  x * y
   - d h - c g - b f + a e + (c h - d g + a f + b e)e
                                                     1
   + 
     (- b h + a g + d f + c e)e  + (a h + b g - c f + d e)e e
                               2                           1 2
              Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

  y * x
   - d h - c g - b f + a e + (- c h + d g + a f + b e)e
                                                       1
   + 
     (b h + a g - d f + c e)e  + (a h - b g + c f + d e)e e
                             2                           1 2
                  Type: CliffordAlgebra(2,Fraction Polynomial Integer,MATRIX)

====================================================================
The Exterior Algebra on a Three Space
====================================================================

This is the field over which we will work, rational functions with
integer coefficients.

  K := Fraction Polynomial Integer
   Fraction Polynomial Integer
                  Type: Domain

If we chose the three by three zero quadratic form, we obtain
the exterior algebra on e(1),e(2),e(3).

  Ext := CliffordAlgebra(3, K, quadraticForm 0)
   CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)
                  Type: Domain

This is a three dimensional vector algebra.  We define i, j, k as the
unit vectors.

  i: Ext := e(1)
   e
    1
             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

  j: Ext := e(2)
   e
    2
             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

  k: Ext := e(3)
   e
    3
             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

Now it is possible to do arithmetic.

  x := x1*i + x2*j + x3*k
   x1 e  + x2 e  + x3 e
       1       2       3
             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

  y := y1*i + y2*j + y3*k
   y1 e  + y2 e  + y3 e
       1       2       3
             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

  x + y
   (y1 + x1)e  + (y2 + x2)e  + (y3 + x3)e
             1             2             3
             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

  x * y + y * x
   0
             Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

On an n space, a grade p form has a dual n-p form.  In particular, in
three space the dual of a grade two element identifies 
 
  e1*e2 -> e3, e2*e3 -> e1, e3*e1 -> e2.

  dual2 a == coefficient(a,[2,3]) * i + coefficient(a,[3,1]) * j + coefficient(a,[1,2]) * k 
                      Type: Void

The vector cross product is then given by this.

  dual2(x*y)
   (x2 y3 - x3 y2)e  + (- x1 y3 + x3 y1)e  + (x1 y2 - x2 y1)e
                   1                     2                   3
           Type: CliffordAlgebra(3,Fraction Polynomial Integer,MATRIX)

====================================================================
The Dirac Spin Algebra
====================================================================

In this section we will work over the field of rational numbers.

  K := Fraction Integer
   Fraction Integer
                       Type: Domain

We define the quadratic form to be the Minkowski space-time metric.

  g := matrix [ [1,0,0,0], [0,-1,0,0], [0,0,-1,0], [0,0,0,-1] ]
   +1   0    0    0 +
   |                |
   |0  - 1   0    0 |
   |                |
   |0   0   - 1   0 |
   |                |
   +0   0    0   - 1+
                       Type: Matrix Integer

We obtain the Dirac spin algebra used in Relativistic Quantum Field Theory.

  D := CliffordAlgebra(4,K, quadraticForm g)
   CliffordAlgebra(4,Fraction Integer,MATRIX)
                       Type: Domain

The usual notation for the basis is gamma with a superscript.  For
Axiom input we will use gam(i):

  gam := [e(i)$D for i in 1..4]
   [e ,e ,e ,e ]
     1  2  3  4
                 Type: List CliffordAlgebra(4,Fraction Integer,MATRIX)

There are various contraction identities of the form

  g(l,t)*gam(l)*gam(m)*gam(n)*gam(r)*gam(s)*gam(t) =
      2*(gam(s)gam(m)gam(n)gam(r) + gam(r)*gam(n)*gam(m)*gam(s))

where a sum over l and t is implied.

Verify this identity for particular values of m,n,r,s.

  m := 1; n:= 2; r := 3; s := 4;
                      Type: PositiveInteger

  lhs := reduce(+, [reduce(+, [ g(l,t)*gam(l)*gam(m)*gam(n)*gam(r)*gam(s)*gam(t) for l in 1..4]) for t in 1..4])
   - 4e e e e
       1 2 3 4
                      Type: CliffordAlgebra(4,Fraction Integer,MATRIX)

  rhs := 2*(gam s * gam m*gam n*gam r + gam r*gam n*gam m*gam s) 
   - 4e e e e
       1 2 3 4
                      Type: CliffordAlgebra(4,Fraction Integer,MATRIX)

See Also:
o )help Complex
o )help Quaternion
o )show CliffordAlgebra
o $AXIOM/doc/src/algebra/clifford.spad

