--Copyright The Numerical Algorithms Group Limited 1991.

)clear all

-- the octonions build a non-associative algebra:

oci1 := octon(1,2,3,4,5,6,7,8)
oci2 := octon(7,2,3,-4,5,6,-7,0)
oci3 := octon(-7,-12,3,-10,5,6,9,0)

oci := oci1 * oci2 * oci3
(oci1 * oci2) * oci3 - oci1 * (oci2 * oci3)

-- the following elements, together with 1, build a basis over the ground ring

octon(1,0,0,0,0,0,0,0)
i := octon(0,1,0,0,0,0,0,0)
j := octon(0,0,1,0,0,0,0,0)
octon(0,0,0,1,0,0,0,0)
octon(0,0,0,0,1,0,0,0)
octon(0,0,0,0,0,1,0,0)
J := octon(0,0,0,0,0,0,1,0)
octon(0,0,0,0,0,0,0,1)

i*(j*J)
(i*j)*J

-- we can extract the coefficient w.r.t. a basis element:
imagi oci
imagE oci

-- 1 and E build a basis with respect to the quaternions:
-- but what are the commuting rules?

qs := Quaternion Polynomial Integer
os := Octonion Polynomial Integer

-- a general quaternion:

q : qs := quatern(q1,qi,qj,qk)
E := octon(0,0,0,0,1,0,0,0)$os

q * E
E * q
q * 1$os
1$os * q


-- two general octonions:


o : os := octon(o1,oi,oj,ok,oE,oI,oJ,oK)
p : os := octon(p1,pi,pj,pk,pE,pI,pJ,pK)


-- the norm of an octonion is defined as the sum of the squares of the 
-- coefficients:


norm o

-- and the norm is multiplicative:
 
norm(o*p)-norm(p*o)
