Let' s  start  with  the  A - roof  genus .

X=Series[x/ (Exp[x/2]-Exp[-x/2]),{x,0,10}]

We replace (x^2) by t w, as Mathematica can’t directly compute the elementary symmetric polynomial of ((Subscript[x, i])^2).

AroofOne[w_]=(X//Normal)/. x^n_ :>  t^n w^(n/2)

And multiply n/2 factors.

AroofSplit=Product[AroofOne[y[i] ],{i,1,5}];

SymmetricReduction converts the result as a polynomial in the Pontryagin classes:

red[X_,d_]:=SymmetricReduction[X,Table[y[i],{i,1,d/2}],Table[(Subscript[p, i]),{i,1,d/2}]][[1]]

Aroof=red[AroofSplit,10]+O[t]^10

Next is the Chern characters of the orthogonal bundles .

We  follow  the  same  approaches.

Y=Series[Exp[x]+Exp[-x],{x,0,10}]

chOne[w_]=(Y//Normal)/. x^n_ :>  t^n w^(n/2)

chSplit=Sum[chOne[y[i] ],{i,1,5}];

So  the Chern character in the vector representation is, for example,

ch[10]=red[chSplit,10]+O[t]^10

So  far we cheated by taking a fixed dimension (10). The general answer can be obtained by changing the constant term:

ch[N_]:= ch[10]-10+N

The Chern character in the adjoint is

adjcontrib[r_]:=r+Sum[ Exp[(z[i]+z[j])t]+Exp[(z[i]-z[j])t]+Exp[(-z[i]+z[j])t]+Exp[(-z[i]-z[j])t]+O[t]^7,{i,1,r},{j,i+1,r}]

which  for  SO (32) is

so32adj=SymmetricReduction[(adjcontrib[16]//Normal//Expand )/.{z[i_]^2:> w[i],z[i_]^4:> w[i]^2,z[i_]^6:> w[i]^3},Table[w[i],{i,1,16}],Table[(Subscript[q, i]),{i,1,16}]][[1]]+O[t]^7

Let' s  next  compute the same for E8. We use the so(16) subalgebra:

so16adj=SymmetricReduction[(adjcontrib[8]//Normal//Expand )/.{z[i_]^2:> w[i],z[i_]^4:> w[i]^2,z[i_]^6:> w[i]^3},Table[w[i],{i,1,8}],Table[(Subscript[q, i]),{i,1,8}]][[1]]+O[t]^7

Weights of a chiral spin representation can be obtained either programmatically

spinweights=Select[Flatten[Outer@@{List}~Join~Table[{-1,1},8],7],(Times@@#) ==+1 &];

spincontrib=(Plus@@(Exp[t #/2]&/@(spinweights. Table[z[i],{i,1,8}])))+O[t]^7;

or   using   the   generating  function :

altspincontrib=(1/2)(Product[Exp[t z[i]/2]+Exp[-t z[i]/2],{i,1,8}]-Product[Exp[t z[i]/2]-Exp[-t z[i]/2],{i,1,8}])+O[t]^7;

spincontrib==altspincontrib//Simplify

In  either  case, we have

so16spin=SymmetricReduction[(spincontrib//Normal//Expand )/.{z[i_]^2:> w[i],z[i_]^4:> w[i]^2,z[i_]^6:> w[i]^3},Table[w[i],{i,1,8}],Table[(Subscript[q, i]),{i,1,8}]][[1]]+O[t]^7

So  the  adjoint of E8 can be obtained as the sum:

e8adj=so16adj+so16spin

e8adjprime=e8adj/.q->r

Let’s combine the results so far and compute the anomaly polynomials of N=1 supergravity theories:

The  anomaly polynomial of the gauginos are:

adj32fermion=Coefficient[(1/2)Aroof so32adj //Normal,t^6]//Expand

adjE8E8fermion=Coefficient[(1/2)Aroof (e8adj+e8adjprime) //Normal,t^6]//Expand

The   anomaly  polynomial  of  the  gravitino  and  the  dilatino  can  be  similarly  computed, by regarding it as a spinor with an additional vector index, minus 4 spinors, as explained in the lecture:

gravitinodilatino=Coefficient[(1/2)Aroof (ch[12]-4) //Normal,t^6]//Expand

We  then  see  the factorization clearly, in both cases:

adj32fermion+gravitinodilatino//Simplify

adjE8E8fermion+gravitinodilatino//Simplify

Finally let’s discuss Type IIB, which contains a self-dual form field.

The  anomaly polynomial of self-dual form field is written in terms of the L-polynomial. Let’s compute it using the same technique as above.

One  factor is

Z=Series[x(Exp[x]+Exp[-x])/ (Exp[x]-Exp[-x]),{x,0,10}]

LOne[w_]=(Z//Normal)/. x^n_ :>  t^n w^(n/2)

We  multiply them and rewrite the result in terms of Pontryagin classes:

LSplit=Product[LOne[y[i] ],{i,1,5}];

L=red[LSplit,10]+O[t]^10

The  anomaly polynomial of a self-dual field is -1/8 of the L-polynomial:

fiveform=-Coefficient[L//Normal,t^6]/8//Expand

We   see   that   it   cancels   against   two   sets   of   gravitino + dilatino :

fiveform + 2gravitinodilatino//Expand