FUNCTION: LieTools/PBWexpand
USAGE: PBWexpand(upoly);
SYNOPSIS: PBWexpand is a procedure that maps an element of U[g], expressed as a 
  sum of products of elements of g with constant coefficients, to its equivalent
  expression in a Poincare-Birchoff-Witt basis.
CAVEATS: requires a previously initialized global Lie algebra environment.
  (See LieTools[gSetup].)
EXAMPLE: 
> with(LieTools):
> gSetup(G,2);
Setting up Gtype = G   rnk = 2
> C2 := 1/8*u(g[1],g[14])+1/8*u(g[14],g[1])+1/8*u(g[2],g[13])+1/8*u(g[13],g[2])+\
        1/24*u(g[3],g[12])+1/24*u(g[12],g[3])+1/24*u(g[4],g[11])+1/24*u(g[11],g[4])+\
        1/8*u(g[10],g[5])+1/8*u(g[5],g[10])+1/24*u(g[6],g[9])+1/24*u(g[9],g[6])+ \
        1/12*u(g[7],g[7])+1/8*u(g[8],g[7])+1/8*u(g[7],g[8])+1/4*u(g[8],g[8]);

  C2 := 1/8 u(g[1], g[14]) + 1/8 u(g[14], g[1]) + 1/8 u(g[2], g[13])

         + 1/8 u(g[13], g[2]) + 1/24 u(g[3], g[12])

         + 1/24 u(g[12], g[3]) + 1/24 u(g[4], g[11])

         + 1/24 u(g[11], g[4]) + 1/8 u(g[10], g[5])

         + 1/8 u(g[5], g[10]) + 1/24 u(g[6], g[9])

         + 1/24 u(g[9], g[6]) + 1/12 u(g[7], g[7])

         + 1/8 u(g[8], g[7]) + 1/8 u(g[7], g[8]) + 1/4 u(g[8], g[8])

> PBWexpand(C2);

  1/4 u(g[1], g[14]) + 1/4 u(g[2], g[13]) + 1/12 u(g[3], g[12])

         + 1/12 u(g[4], g[11]) + 1/4 u(g[5], g[10])

         + 1/12 u(g[6], g[9]) + 1/12 u(g[7], g[7])

         + 1/4 u(g[7], g[8]) + 1/4 u(g[8], g[8]) + 5/12 u(g[7])

         + 3/4 u(g[8])

SEE ALSO: 
