dim 8
v=e124+e235+e346+e457+e561+e672+e713;
w=v/e1234567;
oct(x,y)=Pu(1,x e8 y*(1+w)(1-e12345678));
Tri(F)=e8 1/2(F-w.F-e12345678.(w^F))/e8;
say Trialities of elements in  $wSpin(8)$c, and of bivectors in $wdimension 8$c, are
say realized in the Clifford algebra  $wCl_8 = M_16(R)$c.  For instance, compute
exp(e12 pi)
exp(Tri(e12 pi))
exp(Tri(Tri(e12 pi))) 
exp(Tri(Tri(Tri(e12 pi))))
say
say and you can see that triality, which is of order three, permutes the three
say central elements  $y-1$c, $ye12345678$c, $y-e12345678$c  of the spin group  $wSpin(8)$c.
say $mTo continue press <CARRIAGE RETURN> or <ENTER>
pause
say Here octonions are regarded as vectors in  R^8.  The unit element is
say the vector  e8.  The octonion product of two vectors  x  and  y  in the
say Cayley algebra  O  is computed as  oct(x,y).  For instance, compute
x=4e1+e3+2e4+6e6+3e8
oct(x,e8)
y=2e1+7e2+3e5+4e8
oct(x,y)
say
say $mPress <CARRIAGE RETURN> or <ENTER>
pause
say The Cayley algebra  O  is alternative, i.e.  x(xy)=(xx)y  and  (xy)y=x(yy),
say which implies flexibility, that is, no parentheses are needed in  xyx
oct(x,oct(y,x))
oct(oct(x,y),x)
say
say and also a norm-preserving, that is,  |xy| = |x| |y|
abs(oct(x,y))
abs(x) abs(y)
say
say $mPress <CARRIAGE RETURN>
pause
say Freudenthal's principle of triality means for a bivector  F, say
F=(3e12+2e16+3e17+6e25+3e28+3e34+e36+e47+e57+2e68)/10
say
say that the following two expressions are equal
oct(x,y).(e8 F/e8)
oct(x.Tri(F),y)+oct(x,y.Tri(Tri(F)))
pause
say Cartan's principle of triality means that for  u0=exp(F),  u1=exp(Tri(F))
say and  u2=exp(Tri(Tri(F)))  in the spin group  Spin(8), the expression
u0=exp(F);
u1=exp(Tri(F));
u2=exp(Tri(Tri(F)));
(e8 u0/e8) oct(x,y)/(e8 u0/e8)
say
say equals the following     $m... this might take a while ... just wait
oct(u1 x/u1,u2 y/u2)
say
say $mPress <CARRIAGE RETURN>
pause
say A bivector  F  can be decomposed in two ways into a sum  F=A+B=G+H  where
say G  is in the exceptional Lie algebra  G_2  and  B  is a bivector in  spin(7)
B=(F^e8)/e8
A=F-B
H=1/3(w.(w^F))
G=F-H
pause
say $gNext, two results first published in my book P. Lounesto: 
say $gClifford Algebras and Spinors, Cambridge UP, (2nd ed.) 2001:
say
say 1) The triality automorphism of  Spin(8)  is a restriction of a polynomial
say    mapping  Cl_8 -> Cl_8, of degree two.
say
say 2) The composition of two trialities with respect to different octonion
say    products, both having the same neutral axis, is again a triality, but
say    with respect to an octonion product with a different neutral axis.
say
say $wHere you have a demo of the above two theorems, found with CLICAL.
say
say Triality of  u  in  Spin(8)  is computed by the command  trial(w,n,u)  where
say w  is a 4-vector indicating the octonion product and  n  is the neutral axis.
say The octonion product of  x  and  y  is computed by the command  o(w,n,x,y).
say
pause
Swap(w,F)=1/2(F-w.F-j.(w^F))
Trial(w,n,F)=n Swap(w,F)/n
Pu06(u)=Re(u)+Pu(6,u)
n(n,u)=((u*(1+j))^n)/n
o(w,n,x,y)=Pu(1,x n y*(1+w)(1-j))
w(w,u)=(3-w) u/(3-w)
trial1(w,n,u)=1/2(1+j)Pu06(n(n,n u/n)(1+w))+1/2(1-j)
trial2(w,n,u)=w(w,n(n,u))
trial(w,n,u)=trial1(w,n,u)trial2(w,n,u)
pause
say
say Observe that  trial(w,n,u)  is quadratic in  u  (in fact it is a product
say of a real linear and affine linear function of  u).
pause
say First, rotate the 4-vector
w
say
say by elements in  Spin(7)  to get the 4-vectors of two new octonion products
s1=exp((2e12+3e23+4e56)/10);
s2=exp((3e25+4e47+5e67)/10);
w1=s1 w s1~
w2=s2 w s2~
say
pause
say Then compute the composition of the two trialities
koe1=trial(w1,e8,trial(w2,e8,u0))
say
pause
say Then find out the new octonion product with 4-vector
w12=1/2(w1+w2+j w2-j w1)
say
say and with the neutral axis  n12  computed as follows
x-(1/4)((x.w12).w12)
n12=ans/abs(ans)
say
pause
say Then compute the new triality composed with itself
koe2=trial(w12,n12,trial(w12,n12,u0))
say
say and find that  |koe1-koe2| = 0
abs(koe1-koe2)
pause
say Verify by experimentation that Cartan's principle of triality holds for
say the new triality with respect to 4-vector  w12.
say
say $m  ... the preliminary computations of x1 and y1 might take a while ... 
x1=trial(w12,n12,u0) x trial(w12,n12,u0)~
y1=trial(w12,n12,trial(w12,n12,u0)) y trial(w12,n12,trial(w12,n12,u0))~
o(w12,n12,x1,y1)
(n12 u0/n12) o(w12,n12,x,y) (n12 u0/n12)~
say
say $mEnd of the external file TRIALITY
