--before running code, choose your n. n=8; R = ZZ/21977[x_0..x_9,b_0..b_9,z,Degrees=>{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0}]; F = (i,j) -> if i==j then 1 else 0; --PART 1: GENERAL CODE FOR DIVISOR IN M_{0,n} SPECIFIED BY POLYNOMIAL --this part of the code applies to any divisor in M_{0,n} given b a polynomial equation in n variables. Output is class of pullback in M_{0,n+1}. --to compute classes, we need multiplicities along partial diagonals. --this part of the code picks out relevant diagonals, and encodes them in a matrix. u= matrix table(1,2^n,(i,j)-> if j<2^(n-1) then 1 else 0); V = matrix table(n,2^n,(i,j)->u_(0,(2^i*j)%(2^n)) ); W = matrix table(n,2^n, (i,j)-> if sum(for i from 0 to n-1 list F(1,V_(i,j)))==n or sum(for i from 0 to n-1 list F(1,V_(i,j)))<3 then 0 else V_(i,j)); --next make substitutions along the diagonals: given a polynomial P, (Y(P)) gives a matrix with each collumn encoding a diagonal in the first n entries and multiplicity in the n+1st. --BB(LL(Y(P))) encodes the calss a polynomial. E_I <-> monomial that is product of x_i's for i in I. --If the mutliplicity along a diagonal Delta_{0,1,2} is m, this contributes -m*x_3*x_4*x_5...*x_(n-1) = -m*E_{345..(n-1)} to the class. g = (i,j) -> if i sub(P,{x_0=>g(0,l), x_1=>g(1,l), x_2=>g(2,l), x_3=>g(3,l), x_4=>g(4,l), x_5=>g(5,l), x_6=>g(6,l),x_7=>g(7,l),x_8=>g(8,l),x_9=>g(9,l)}); Y = P -> for i from 0 to 2^n-1 list matrix table(n+1,1,(j,l) -> if h(i,P)==0 or first degree(h(i,P))==0 then 0 else if j==n then (first degree(h(i,P))) else F(0,W_(j,i) )*(x_(j)) ); a = v-> if v_(n,0) == 0 then 0 else product(flatten(entries((compress transpose v)))); LL = Y -> apply(Y,a); BB= LL -> sum LL; T = P-> BB(LL(Y(P)))-first degree(P)*z; --PART 2: HYPERTREE DIVISORS --given a hypertree, generate a polynomial describing the correspondin divisor in M_{0,n} -- given a matrix encoding the hypertrees for a given n, the determinantal equation and class are computed here. -- input your hypertree as a row matrix length 3*n-2. --End result is a function such that D(i) is the divisor corresponding to the ith hypertree. -- Code is specialized for n between 6 and 10 but the mechanisms for computing the polynomial and class are general. H = matrix{{0+0*x_0,-1,1},{1,0,-1},{-1,1,0}}; O = v-> matrix table(n-2,3, (i,j) -> v_(0, 3*i+j)); Q = O -> matrix table (n-2,3, (i,j)->(x_(O_(i,j)))) ; M = A-> matrix table(n-2,n,(i,j)-> sum( for l from 0 to 2 list ((A*H)_(i,l))*(F (x_j, A_(i,l) ) ) ) ); N = (M,v)-> matrix table(n-2,n, (i,j) -> if sum( for l in {v_(0,0), v_(0,1), v_(0,2)} list F(l,j) ) == 0 then M_(i,j) else 0) ; s= O ->product(for i from 0 to n-3 list (x_(O_(i,0))-x_(O_(i,1)))) ; P= (N,O)-> sub( (generator radical ideal (s(O)))*(det compress transpose compress N)/(s(O)),R); c= v -> T(P(N(M(Q(O(v))),v),O(v))); --encode entire set of hypertrees for a given n as collumns of matrix HT. -- HT matrix and nn (number of hypertrees) are decided based on input n. HT= i -> if i== 6 then matrix{{0,1,2,3,1,4,0,4,5,3,2,5}} else if i==7 then matrix{{0,1,2,0,3,4,1,3,5,0,5,6,2,4,6}} else if i==8 then matrix{{0,1,2,0,1,3,0,4,5,1,6,7,2,4,6,3,5,7},{0,1,2,3,4,5,0,6,7,1,3,6,2,4,7,1,5,7},{0,1,2,3,4,5,0,3,6,1,4,6,0,5,7,2,4,7}} else if i ==9 then matrix{{0,1,2,0,1,3,0,4,5,1,6,7,2,4,8,3,5,6,0,7,8},{0,1,2,0,1,3,4,5,6,0,4,7,1,5,8,2,6,7,3,4,8},{0,1,2,0,1,3,4,5,6,0,7,8,1,4,7,2,5,8,3,6,7},{0,1,2,3,4,5,6,7,8,0,3,6,1,4,7,2,5,8,0,4,8},{0,1,2,3,4,5,0,6,7,1,3,8,2,4,6,5,7,8,0,4,8},{0,1,2,3,4,5,0,6,7,1,6,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1,4,6,2,5,7,0,4,8,1,5,9},{0,1,2,3,4,5,0,6,7,1,3,8,2,4,6,5,7,8,0,4,9,1,5,9},{0,1,2,3,4,5,0,6,7,1,3,8,2,4,6,2,3,7,0,8,9,1,5,9},{0,1,2,3,4,5,0,6,7,3,8,9,1,4,6,1,7,8,2,3,6,1,5,9},{0,1,2,3,4,5,0,6,7,1,3,8,2,4,6,0,8,9,5,7,9,1,6,9},{0,1,2,3,4,5,0,6,7,3,8,9,1,4,6,2,5,8,0,4,9,1,7,8},{0,1,2,3,4,5,6,7,8,0,3,9,1,4,6,2,5,7,0,4,8,1,7,9},{0,1,2,3,4,5,0,6,7,1,3,8,1,4,6,2,8,9,0,5,9,1,7,9},{0,1,2,3,4,5,0,6,7,1,3,8,2,4,6,5,7,8,0,8,9,1,7,9},{0,1,2,3,4,5,0,6,7,1,3,8,2,4,6,0,5,8,3,6,9,1,7,9},{0,1,2,3,4,5,6,7,8,0,3,6,1,4,7,2,5,8,0,4,9,1,8,9},{0,1,2,3,4,5,6,7,8,0,3,9,1,4,9,2,5,6,0,5,7,2,3,8},{0,1,2,3,4,5,0,6,7,1,3,8,4,6,9,0,5,8,1,4,7,2,3,9},{0,1,2,3,4,5,0,6,7,1,3,8,4,6,9,2,5,8,0,3,9,2,4,7},{0,1,2,3,4,5,0,6,7,1,3,8,1,4,6,2,8,9,0,5,9,2,5,7},{0,1,2,3,4,5,0,6,7,3,8,9,1,4,6,1,5,8,1,3,7,2,6,9},{0,1,2,3,4,5,0,6,7,1,3,8,0,4,9,2,3,6,0,5,8,3,7,9},{0,1,2,3,4,5,0,6,7,1,3,8,1,4,6,2,8,9,0,5,9,3,7,9}} ; D = i -> matrix{{c( submatrix(HT(n),{i},) )}}; --note: D(i) is a matrix to make macaulay preserve subscripts nn = i -> if n == 6 then 0 else if n ==7 then 0 else if n==8 then 2 else if n ==9 then 10 else if n == 10 then 96; D = i -> matrix{{c( submatrix(HT(n),{i},) )}}; --note: D(i) is a matrix to force macaulay to preserve subscripts in the polynomial -- print out divisors in form Di = (..polynomial..), with Di corresponding to the divisor encoded in the ith column of HT(n). scan(0..nn(n), i-> <<"D"< for i from 0 to n-3 list (i,v_(0,i)); ff = (i,j) -> if j>0 then (x_(n-2)-x_i)^(j) else (x_(n-1)-x_i)^(-j); gg= L -> product(apply(L,ff)); r= u-> u - sub(u,{x_(n-1)=>x_(n-2),x_(n-2)=>x_(n-1)}); p = v->sub(r(gg(L(v)))/(x_(n-2)-x_(n-1)),R); G = v->T(p(v));