###################################################################### ##PERCYG.txt: Save this file as PERCYG.txt # ## To use it, stay in the # ##same directory, get into Maple (by typing: maple ) # ##and then type: read PERCYG.txt # ##Then follow the instructions given there # ## # ##Written by Doron Zeilberger, Rutgers University , # #zeilberg at math dot rutgers dot edu # ###################################################################### #Created: June 13, 2016 print(`Created: June 13, 2016`): print(` This is PERCYG.txt `): print(`It is the Maple package that generated the article `): print(` On the Most Commonly-Occuring Score Vectors of American Tournaments of n-players, and their Corresponding Records `): print(`by Shalosh B. Ekhad`): print(`and also available from Zeilberger's website`): print(``): print(`Please report bugs to zeilberg at math dot rutgers dot edu`): print(``): print(`The most current version of this package and paper`): print(` are available from`): print(`http://www.math.rutgers.edu/~zeilberg/ .`): print(`---------------------------------------`): print(`For a list of the Supporting procedures type ezra1();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the MAIN procedures type ezra();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the Supporting procedures for the special case of American tournaments type ezraA1();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): print(`---------------------------------------`): print(`For a list of the MAIN procedures of the special case of American tournaments type ezraA();, for help with`): print(`a specific procedure, type ezra(procedure_name); .`): print(``): print(`---------------------------------------`): with(combinat): ezra1:=proc() if args=NULL then print(` The supporting procedures are: CGn, ParsG `): print(``): else ezra(args): fi: end: ezra:=proc() if args=NULL then print(`The main procedures for the general case are: CG, GGF, MCG, MCGdetail, PercyChess, PercyG, PercyGDetail, PercySoccer `): print(` `): elif nops([args])=1 and op(1,[args])=CG then print(`CG(L,p,x,y): inputs a score vector L, and a polynomial p in x,y, and outputs the number of tournaments with seed p(x,y)`): print(`that score-vector. Try`): print(`CG([2,1,0],x+y,x,y);`): elif nops([args])=1 and op(1,[args])=CGn then print(`CGn(L,p,x,y): inputs a polynomial p in the variables x,y, and score vector, of length n, say, and outputs the coefficient`): print(`of x[1]^L[1]*...x[n]^L[n] done in the Naive way. Try:`): print(`CGn([2,1,0],x+y,x,y);`): elif nops([args])=1 and op(1,[args])=GGF then print(`GGF(n,W,L,P,G): inputs a positive integer n, and symbols W,L,P, outputs a rational function in the`): print(`3*n variables, W[1], ..., W[n], L[1], ..., L[n], P[1], ..., P[n] whose coefficient of`): print(`W[1]^w[1]*...*W[n]^w[n]*L[1]^l[1]*...*L[n]^l[n]**P[1]^p[1]*...*P[n]^p[n]*G^g is the number of ways`): print(`in a round-robin Soccer tournament with n teams,`): print(`team i had w[i] Goals For, l[i] Goals Against, and p[i] points (where a win gets you three points, a loss nothing, and a draw one point).`): print(`and the total number of goals scored was g`): print(`Try:`): print(`GGF(3,W,L,P,G);`): elif nops([args])=1 and op(1,[args])=GGGF then print(`GGGF(n,W,L,P,G): inputs a positive integer n, and symbols W,L,P, outputs a rational function in the`): print(`3*n variables, W[1], ..., W[n], L[1], ..., L[n], P[1], ..., P[n] whose coefficient of`): print(`W[1]^w[1]*...*W[n]^w[n]*L[1]^l[1]*...*L[n]^l[n]**P[1]^p[1]*...*P[n]^p[n]*G^g is the polynomial in the W[i,j]'s`): print(`whose power indicates how many goals i scored against j.`): print(`in a round-robin Soccer tournament with n teams,`): print(`team i had w[i] Goals For, l[i] Goals Against, and p[i] points (where a win gets you three points, a loss nothing, and a draw one point).`): print(`and the total number of goals scored was g`): print(`Try:`): print(`GGGF(3,W,L,P,G);`): elif nops([args])=1 and op(1,[args])=MCG then print(`MCG(n,p,x,y): inputs a positive integer n, and outputs the most popular score-vector in a generalized tournament`): print(`whose seed is the polynomial p in x, y (describing the possible scoring in one match between x and y)`): print(`together with the number of tournaments realizing it.`): print(`Try: MCG(4,x+y,x,y);`): elif nops([args])=1 and op(1,[args])=MCGdetail then print(`MCGdetail(n,p,x,y): inputs a positive integer n, and outputs the most popular score-vector in a generalized tournament`): print(`whose seed is the polynomial p in x, y (describing the possible scoring in one match between x and y)`): print(`together with the number of tournaments realizing it.`): print(`it also outputs a list of all score vectors with their associated number of occurrences`): print(`Try: MCGdetail(4,x+y,x,y);`): elif nops([args])=1 and op(1,[args])=ParsG then print(`ParsG(N,n,p,x,y): the set of partitions of N into n-parts including 0 with largest part <=n*degree(p,{x,y}). Try:`): print(`ParsG(6,4,x+y,x,y);`): elif nops([args])=1 and op(1,[args])=PercyChess then print(`PercyChess(N): inputs a positive integer N and outputs an article about all the possible score vectors`): print(`in a round-robin Chess Tournament with N players. The score-vectors are doubled, to avoid fractions.`): print(` Try: `): print(` PercyChess(6); `): elif nops([args])=1 and op(1,[args])=PercyG then print(`PercyG(N,p,x,y): inputs a positive integer N, and a polynomial p in x,y,`): print(`and outputs the first N terms (starting with n=2) of the analog of OEIS sequence A274098`): print(`for round-robin tournaments where the generating founction for ONE match between x and y`): print(`is given by the polynomial p. Try:`): print(`PercyG(5,x^2+x*y+y^2,x,y);`): elif nops([args])=1 and op(1,[args])=PercyGDetail then print(`PercyGDetail(N,p,x,y): inputs a positive integer N, and polynomial p of x and y and outputs extensive tables like MacMahon's`): print(`but for a tournament where the generating function of the possibe scores of a single match between x and y is given by p`): print(`For Tennis, do: PercyGDetail(5,x+y,x,y) (same as PercyDetail(N))`): print(`For Chess, do: PercyGDetail(5,x^2+x*y+y^2,x,y) ;`): print(`For Soccer, do: PercyGDetail(5,x^3+x*y+y^3,x,y) ;`): elif nops([args])=1 and op(1,[args])=PercySoccer then print(`PercySoccer(N): inputs a positive integer N and outputs an article about all the possible score vectors`): print(`in a round-robin Soccer Tournament with N players.`): print(` Try: `): print(` PercySoccer(6); `): else print(`There is no ezra for`,args): fi: end: ##start special case of usual Tennis Tournaments ezraA1:=proc() if args=NULL then print(` The supporting procedures are: C, Pars, Pars1, PtoM, Vecs`): print(``): else ezra(args): fi: end: ezraA:=proc() if args=NULL then print(`The main procedures for the simple case (Tennis, no draws) are: MC, MCdetail, MCdetailV, Percy, PercyDetail `): print(` `): elif nops([args])=1 and op(1,[args])=C then print(`C(L): inputs a score vector and outputs the number of tournaments with that score-vector. Try`): print(` C([2,1,0]); `): elif nops([args])=1 and op(1,[args])=MC then print(`MC(n): inputs a positive integer n, and outputs the most popular score-vector together with the number of tournaments realizing it.`): print(`Try: MC(4);`): elif nops([args])=1 and op(1,[args])=MCdetail then print(`MCdetail(n): inputs a positive integer n, and outputs the most popular score-vector together with the number of tournaments realizing it.`): print(`and also lists all the score vectors with their number of occurrences`): print(`Try: MCdetail(4);`): elif nops([args])=1 and op(1,[args])=MCdetailV then print(`MCdetailV(n): verbose versioon of MCdetail(n), q.v., using MacMahon's format for displaying his tables. `): print(`Try: MCdetailV(4);`): elif nops([args])=1 and op(1,[args])=Mul then print(`Mul(L): the multiplicity of the partition L. Try:`): print(`Mul([3,3,2,2,2]);`): elif nops([args])=1 and op(1,[args])=Pars then print(`Pars(N,n): the set of partitions of N into n-parts including 0. such that L[i]<=n-i and the score-vector condition is fullfiled.Try:`): print(`Pars(6,4);`): elif nops([args])=1 and op(1,[args])=Pars1 then print(`Pars1(N,k,n): the set of partitions of N into n-parts including 0, with largest part k and the score-vector of tournament conditions. Try`): print(`Pars1(6,2,4);`): elif nops([args])=1 and op(1,[args])=Percy then print(`Percy(N): inputs a positive integer N, and generates an article extending P.A. MacMahon's article about American tournaments. `): print(`In particular, it gives the first N terms (starting with n=2) of the OEIS sequence A274098. Try:`): print(`Percy(10); `): elif nops([args])=1 and op(1,[args])=PercyDetail then print(`PercyDetail(N): inputs a positive integer N, and generates an article extending P.A. MacMahon's atricle about American tournaments. `): print(`In particular, it gives the first N terms (starting with n=2) of the OEIS sequence A274098. It gives full details.`): print(` like MacMahon's `): print(` Try: `): print(`PercyDetail(10); `): elif nops([args])=1 and op(1,[args])=PtoM then print(`PtoM(L): Given a partition L converts it to multiplicity notation. Try:`): print(`PtoM([3,3,3,2,2,2,2]); `): elif nops([args])=1 and op(1,[args])=Vecs then print(`Vecs(m,n): all the 0-1 vectors of length n that add-up to m (or with m 1s). Try:`): print(` Vecs(4,2); `): else print(`There is no ezra for`,args): fi: end: with(combinat): #Pars1(N,k,n): the set of partitions of N into n-parts including 0, with largest part k and the score-vector of tournament conditions. Try #Pars1(6,2,4); Pars1:=proc(N,k,n) local gu,k1,mu,mu1,i1: option remember: if n=1 then if N=k then RETURN([[N]]): else RETURN([]): fi: fi: if k>N then RETURN([]): fi: gu:=[]: for k1 from k by -1 to 0 do mu:=Pars1(N-k,k1,n-1): for i1 from 1 to nops(mu) do mu1:=mu[i1]: if convert(mu1,`+`)>=binomial(n,2)-k then gu:=[op(gu), [k,op(mu1)]]: fi: od: od: gu: end: #Pars(N,n): the set of partitions of N into n-parts including 0. such that L[i]<=n-i and the score-vector condition is fullfiled.Try: #Pars(6,4); Pars:=proc(N,n) local k1: option remember: if n=0 then if N=0 then RETURN([[]]): else RETURN([]): fi: fi: [seq(op(Pars1(N,n-k1,n)),k1=0..n)]: end: #Vecs(m,n): all the 0-1 vectors of length n that add-up to m (or with m 1s). Try: #Vecs(4,2); Vecs:=proc(m,n) local mu0,mu1,mu0a,mu1a: option remember: if n=0 then if m=0 then RETURN({[]}): else RETURN({}): fi: fi: if m<0 or m>n then RETURN({}): fi: mu0:=Vecs(m,n-1): mu1:=Vecs(m-1,n-1): {seq([0,op(mu0a)],mu0a in mu0)} union {seq([1,op(mu1a)],mu1a in mu1)} : end: #C(L): inputs a score vector and outputs the number of tournaments with that score-vector. Try #C([2,1,0]); C:=proc(L) local n,i,lu,lu1, L2,gu: option remember: n:=nops(L): if convert(L,`+`)<>binomial(n,2) then RETURN(FAIL): fi: if n=1 then RETURN(1): fi: lu:=Vecs(n-1-L[1],n-1): gu:=0: for lu1 in lu do L2:=sort([seq(L[i]-lu1[i-1],i=2..n)]): gu:=gu+C(L2): od: gu: end: #PtoM(L): Given a partition L converts it to multiplicity notation PtoM:=proc(L) local i,L1: if L=[] then RETURN([]): fi: for i from 1 to nops(L) while L[i]=L[1] do od: i:=i-1: L1:=[op(i+1..nops(L),L)]: [[L[1],i],op(PtoM(L1))]: end: #Mul(L): the multiplicity of the partition L Mul:=proc(L) local gu,i: gu:=PtoM(L): gu:=[seq(gu[i][2],i=1..nops(gu))]: convert(gu,`+`)!/mul(gu[i]!,i=1..nops(gu)): end: #MC(n): inputs a positive integer n, and outputs the most popular score-vector together with the number of tournaments realizing it. #Try: MC(4); MC:=proc(n) local si,gu,gu1,alufim,hal: gu:=Pars(binomial(n,2),n): si:=0: for gu1 in gu do hal:=C(gu1)*Mul(gu1): if hal>si then alufim:={gu1}: si:=hal: elif hal=si then alufim:=alufim union {gu1}: fi: od: si,alufim: end: #MCdetail(n): inputs a positive integer n, and outputs the most popular score-vector together with the number of tournaments realizing it. #and also lists all the score vectors with their number of occurrences #Try: MCdetail(4); MCdetail:=proc(n) local si,gu,gu1,alufim,hal,lu,i1: option remember: gu:=Pars(binomial(n,2),n): si:=0: lu:=[]: for gu1 in gu do lu:=[op(lu),[gu1,C(gu1),Mul(gu1), C(gu1)*Mul(gu1)]]: hal:=C(gu1)*Mul(gu1): if hal>si then alufim:={gu1}: si:=hal: elif hal=si then alufim:=alufim union {gu1}: fi: od: if add(lu[i1][4],i1=1..nops(lu))<>2^binomial(n,2) then print(`Something is wrong`): RETURN(FAIL): fi: si,alufim,lu: end: #MCdetailV(n): Verbose version of MCdetail(n) (q.v.): #Try: MCdetailV(4); MCdetailV:=proc(n) local gu,si,alufim,lu,a,i,j: gu:=MCdetail(n): si:=gu[1]: alufim:=gu[2]: lu:=gu[3]: print(``): print(`---------------------------------------------------------------------------------`): print(n, `Players. Symmetric Function:`, Product(Product(a[i]+a[j],j=i+1..n),i=1..n)): print(``): print(``): print(`Score Vector`, `Coeff. of Sym. Func. `,`Number of Terms in Sym. Funct.`, `Events in Tournaments.`): print(``): for i from 1 to nops(lu) do print(op(lu[i])): print(``): od: print(`Sum of numbers in last column=`, 2^binomial(n,2)): print(``): print(`The most probable vector is`, alufim[1], `which arises in`, si, ` out of 2 to the power`, binomial(n,2), ` that equals`, 2^binomial(n,2), ` events. `): print(``): print(`---------------------------------------------------------------------------------`): end: #Percy(N): inputs a positive integer N, and outputs the first N terms (starting with n=2) of the OEIS sequence A274098 Percy:=proc(N) local n,gu,mu: print(`On the Most Commonly-Occurring Score Vectors of American Tournaments of n-players, and their Corresponding Records`): print(``): print(`By Shalosh B. Ekhad`): print(``): print(`In his beautiful article, "An American Tournament Treated by the Calculus of Symmetric Functions"`): print(` Quarterly J. of Pure and Applied Mathematics. vol. XLIX, No. 193, 1920`): print(`The Combinatorial Giant, (and amazing human calculator), Major Percy Alexander MacMahon`): print(`considered round-robin tournaments for n players for n from 2 to 9, and for each found all the`): print(`possible score vectors, and determined the most popular one, as well as the number of times it shows up`): print(``): print(`In this article, we continue this work up to n=`, N, `and thereby continue OEIS sequence A274098 `): print(`currently (June 13, 2016) only containing the terms MacMahon computed purely by hand`): print(``): mu:=[]: for n from 2 to N do gu:=MC(n): print(``): print(`------------------------------------------`): print(``): print(`In a torunament with`, n, `players `): if nops(gu[2])>1 then print(`The set of champion score vectors is`, gu[2]): else print(`The sole champion score-vector is`, gu[2][1]): fi: print(`the corresponding record is`, gu[1]): mu:=[op(mu),gu[1]]: od: print(``): print(`------------------------------------------`): print(``): print(`In conclusion, the n=2 thorough n=`, N, `of OEIS sequence A274098 are `): print(``): lprint(mu): print(``): print(`------------------------------------------`): print(``): print(`This ends this article, that took`, time(), `seconds to produce. `): end: #PercyDetail(N): inputs a positive integer N, and outputs extensive tables like MacMahon's PercyDetail:=proc(N) local n,gu,mu: print(`All the Possible Score Vectors in a Round-Robin Tournament, and the Number of Times each Shows Up`): print(`for tournaments from Three to `, N, `players. `): print(``): print(`By Shalosh B. Ekhad`): print(``): print(`In his beautiful article, "An American Tournament Treated by the Calculus of Symmetric Functions"`): print(` Quarterly J. of Pure and Applied Mathematics. vol. XLIX, No. 193, 1920`): print(`The Combinatorial Giant, (and amazing human calculator), Major Percy Alexander MacMahon`): print(`considered round-robin tournaments for n players for n from 2 to 9, and for each found all the`): print(`possible score vectors and, for each, the number of times it shows up`): print(``): print(`In this article, we reproduce the tables done by the Major for n=3 to n=8`): print(`and go all the way to n=`, N): mu:=[]: for n from 3 to N do gu:=MCdetail(n): MCdetailV(n): print(``): print(`------------------------------------------`): print(``): print(`In a torunament with`, n, `players `): if nops(gu[2])>1 then print(`The set of champion score vectors is`, gu[2]): else print(`The sole champion score-vector is`, gu[2][1]): fi: print(`the corresponding record is`, gu[1]): mu:=[op(mu),gu[1]]: od: print(``): print(`------------------------------------------`): print(``): print(`In conclusion, the n=2 thorough n=`, N, `of OEIS sequence A274098 are `): print(``): lprint(mu): print(``): print(`------------------------------------------`): print(``): print(`This ends this article, that took`, time(), `seconds to produce. `): end: ##end special case of usual Tennis Tournaments ##start general case #CGn(L,p,x,y): inputs a polynomial p in the variables x,y, and score vector, of length n, say, and outputs the coefficient #of x[1]^L[1]*...x[n]^L[n] done in the Naive way. Try #CGn([2,1,0],x+y,x,y); CGn:=proc(L,p,x,y) local n,i,j,gu: option remember: n:=nops(L): gu:=mul(mul(subs({x=x[i],y=x[j]},p),i=1..j-1),j=2..n): for i from 1 to n do gu:=coeff(gu,x[i],L[i]): od: gu: end: #CG(L,p,x,y): inputs a score vector L, and a polynomial p in x,y, and outputs the number of tournaments with seed p(x,y) #that score-vector. Try #CG([2,1,0],x+y,x,y); CG:=proc(L,p,x,y) local gu,gu1,C,i,gu11,n,i1,lu,su,lu1,v: option remember: n:=nops(L): if n=1 then if L=[] then RETURN(1): else RETURN(0): fi: fi: if n=2 then RETURN(coeff(coeff(p,x,L[1]),y,L[2])): fi: gu:=expand(coeff(mul(subs(x=x[i],p),i=1..n-1),y,L[n])): if not type(gu,`+`) then gu1:=[seq(degree(gu,x[i]),i=1..n-1)]: C:=normal(gu/mul(x[i]^gu1[i],i=1..n-1)): lu:={[gu1,C]}: else lu:={}: for i1 from 1 to nops(gu) do gu1:=op(i1,gu): gu11:=[seq(degree(gu1,x[i]),i=1..n-1)]: C:=normal(gu1/mul(x[i]^gu11[i],i=1..n-1)): lu:=lu union {[gu11,C]}: od: fi: su:=0: for lu1 in lu do C:=lu1[2]: v:=lu1[1]: su:=su+C*CG(sort([seq(L[i1]-v[i1],i1=1..n-1)]),p,x,y): od: su: end: #Pars1G(N,k,n): the set of partitions of N into n-parts including 0, with largest part k and the score-vector of tournament conditions. Try #Pars1G(6,2,4); Pars1G:=proc(N,k,n) local gu,k1,mu,mu1: option remember: if n=1 then if N=k then RETURN([[N]]): else RETURN([]): fi: fi: if k>N then RETURN([]): fi: gu:={}: for k1 from k to 0 by -1 do mu:=Pars1G(N-k,k1,n-1): for mu1 in mu do gu:=[op(gu),[k,op(mu1)]]: od: od: gu: end: #ParsG(N,n,p,x,y): the set of partitions of N into n-parts including 0. Try: #ParsG(6,4,x+y,x,y); ParsG:=proc(N,n,p,x,y) local k1: option remember: if n=0 then if N=0 then RETURN([[]]): else RETURN([]): fi: fi: [seq(op(Pars1G(N,n*degree(p,{x,y})-k1,n)),k1=0..n*degree(p,{x,y}))]: end: #MCG(n,p,x,y): inputs a positive integer n, and outputs the most popular score-vector in a generalized tournament #whose seed is the polynomial p in x, y (describing the possible scoring in one match between x and y) #together with the number of tournaments realizing it. #Try: MCG(4,x+y,x,y); MCG:=proc(n,p,x,y) local si,gu,gu1,alufim,hal,d1,d2,i,a1: option remember: if n=0 or n=1 then RETURN(1,{[]}): fi: d1:=degree(p,{x,y}): d2:=ldegree(p,{x,y}): gu:=[seq(op(ParsG(a1,n,p,x,y)),a1=d2*binomial(n,2)..d1*binomial(n,2))]: si:=0: for gu1 in gu do hal:=CG(gu1,p,x,y)*Mul(gu1): if hal>si then alufim:={gu1}: si:=hal: elif hal=si then alufim:=alufim union {gu1}: fi: od: si,alufim: end: #PercyG(N,p,x,y): inputs a positive integer N, and a polynomial p in x,y, #and outputs the first N terms (starting with n=2) of the analog of OEIS sequence A274098 #for round-robin tournaments where the generating founction for ONE match between x and y #is given by the polynomial p. Try: #PercyG(4,x^2+x*y+y^2,x,y); PercyG:=proc(N,p,x,y) local n,gu,mu: print(`On the Most Commonly-Occurring Score Vectors of a Round Robin Tournaments of n-players`): print(`Where the Generating Function of the possible scores in ONE match is`, p): print(` and their Corresponding Records`): print(``): print(`By Shalosh B. Ekhad`): print(``): print(`In his beautiful article, "An American Tournament Treated by the Calculus of Symmetric Functions"`): print(` Quarterly J. of Pure and Applied Mathematics. vol. XLIX, No. 193, 1920`): print(`The Combinatorial Giant, (and amazing human calculator), Major Percy Alexander MacMahon`): print(`considered round-robin tournaments for n players for n from 2 to 9, and for each found all the`): print(`possible score vectors, and determined the most popular one, as well as the number of times it shows up`): print(``): print(`This applies to Tennis or Basketball where one winning team gets one point and the losing one gets 0 points`): print(`and there is no draw`): print(`In this article, we do the analog to a scenario where the generating function of the possible scoring outcome`): print(`of a single match is`, p, `.`): print(`(The usual case is the case where p=x+y )`): print(``): mu:=[]: for n from 2 to N do gu:=MCG(n,p,x,y): print(``): print(`------------------------------------------`): print(``): print(`In a torunament with`, n, `players `): if nops(gu[2])>1 then print(`The set of champion score vectors is`, gu[2]): else print(`The sole champion score-vector is`, gu[2][1]): fi: print(`the corresponding record is`, gu[1]): mu:=[op(mu),gu[1]]: od: print(``): print(`------------------------------------------`): print(``): print(`In conclusion, the n=2 thorough n=`, N, `of the`, p, `analog of OEIS sequence A274098 `): print(``): lprint(mu): print(``): print(`------------------------------------------`): print(``): print(`This ends this article, that took`, time(), `seconds to produce. `): end: ##end special case of usual Tennis Tournaments #MCGdetail(n,p,x,y): inputs a positive integer n, and outputs the most popular score-vector in a generalized tournament #whose seed is the polynomial p in x, y (describing the possible scoring in one match between x and y) #it also gives a list of all score vectors and their number of occurences #together with the number of tournaments realizing it. #Try: MCGdetail(4,x+y,x,y); MCGdetail:=proc(n,p,x,y) local si,gu,gu1,alufim,hal,d1,d2,i,lu,i1,a1: option remember: if n=0 or n=1 then RETURN(1,{[]}): fi: d1:=degree(p,{x,y}): d2:=ldegree(p,{x,y}): gu:=[seq(op(ParsG(a1,n,p,x,y)),a1=d2*binomial(n,2)..d1*binomial(n,2))]: si:=0: lu:=[]: for gu1 in gu do hal:=CG(gu1,p,x,y)*Mul(gu1): if hal>0 then lu:=[op(lu),[gu1,CG(gu1,p,x,y), Mul(gu1), hal]]: fi: if hal>si then alufim:={gu1}: si:=hal: elif hal=si then alufim:=alufim union {gu1}: fi: od: if add(lu[i1][4],i1=1..nops(lu))<>subs({x=1,y=1},p)^binomial(n,2) then print(`Something is wrong`): RETURN(FAIL): fi: si,alufim,lu: end: #MCGdetailV(n,p,x,y): Verbose version of MCGdetail(n,p,x,y) (q.v.): #Try: MCGdetailV(4); MCGdetailV:=proc(n,p,x,y) local gu,si,alufim,lu,a,i,j: gu:=MCGdetail(n,p,x,y): si:=gu[1]: alufim:=gu[2]: lu:=gu[3]: print(``): print(`---------------------------------------------------------------------------------`): print(n, `Players. Symmetric Function:`, Product(Product(subs({x=a[i],y=a[j]},p),j=i+1..n),i=1..n)): print(``): print(``): print(`Score Vector`, `Coeff. of Sym. Func. `,`Number of Terms in Sym. Funct.`, `Events in Tournaments.`): print(``): for i from 1 to nops(lu) do print(op(lu[i])): print(``): od: print(`Sum of numbers in last column=`, subs({x=1,y=1},p)^binomial(n,2)): print(``): print(`The most probable vector is`, alufim[1], `which arises in`, si, ` out of`, subs({x=1,y=1},p), `to the power`, binomial(n,2)): print(` that equals`, subs({x=1,y=1},p)^binomial(n,2), ` events. `): print(``): print(`---------------------------------------------------------------------------------`): end: #PercyGDetail(N,p,x,y): inputs a positive integer N, and polynomial p of x and y and outputs extensive tables like MacMahon's #but for a tournament where the generating function of the possibe scores of a single match between x and y is given by p #For Tennis, do: PercyGDetail(N,x+y,x,y) (same as PercyDetail(N)) #For Chess, do: PercyGDetail(N,x^2+x*y+y^2,x,y) ; #For Soccer, do: PercyGDetail(N,x^3+x*y+y^3,x,y) ; PercyGDetail:=proc(N,p,x,y) local n,gu,mu: print(`All the Possible Score Vectors in a Round-Robin Tournament, and the Number of Times each Shows Up`): print(`for tournaments from Three to `, N, `players. `): print(`Where the Generating Function of the Scores of a Single Match is`, p): print(``): print(`By Shalosh B. Ekhad`): print(``): print(`In his beautiful article, "An American Tournament Treated by the Calculus of Symmetric Functions"`): print(` Quarterly J. of Pure and Applied Mathematics. vol. XLIX, No. 193, 1920`): print(`The Combinatorial Giant, (and amazing human calculator), Major Percy Alexander MacMahon`): print(`considered round-robin tournaments for n players for n from 2 to 9, and for each found all the`): print(`possible score vectors and, for each, the number of times it shows up`): print(``): print(`In this article, we do an analogous thing for a tournament for the kind of sport where`): print(`the possible scores have generating function`, p): print(`from n=3 to n=`, N): mu:=[]: for n from 3 to N do gu:=MCGdetail(n,p,x,y): MCGdetailV(n,p,x,y): print(``): print(`------------------------------------------`): print(``): print(`In a torunament with`, n, `players `): if nops(gu[2])>1 then print(`The set of champion score vectors is`, gu[2]): else print(`The sole champion score-vector is`, gu[2][1]): fi: print(`the corresponding record is`, gu[1]): mu:=[op(mu),gu[1]]: od: print(``): print(`------------------------------------------`): print(``): print(`In conclusion, the n=2 thorough n=`, N, `of the champions are `): print(``): lprint(mu): print(``): print(`------------------------------------------`): print(``): print(`This ends this article, that took`, time(), `seconds to produce. `): end: #PercyChess(N): inputs a positive integer N and outputs an article about all the possible score vectors #in a round-robin Chess Tournament with N players. The score-vectors are doubled, to avoid fractions. #Try: #PercyChess(6); PercyChess:=proc(N) local n,gu,mu,x,y: print(`All the Possible Score Vectors in a Round-Robin Chess Tournament, and the Number of Times each Shows Up`): print(`for tournaments from Three to `, N, `players. `): print(``): print(`By Shalosh B. Ekhad`): print(``): print(`In his beautiful article, "Chess Tournament and the like treated by the calculus of Symmetric Functions"`): print(` Quarterly J. of Pure and Applied Mathematics. vol. 49 (1923), 353-384`): print(`The Combinatorial Giant, (and amazing human calculator), Major Percy Alexander MacMahon`): print(`considered round-robin Chess tournaments for n players for n from 2 to 6, and for each found all the`): print(`possible score vectors and for each their number of occurrences.`): print(``): print(`In this article, we reproduce his tables, and go all the way to tournaments with`, N, `players. `): mu:=[]: print(`Recall that in a Chess match with a winner, the winner gets one point, and the loser gets 0 points, and in case of`): print(`a draw, each get half a point. For the sake of conbenience let's double everythinng, so the score vectors below`): print(`should be divided by 2.`): print(``): for n from 3 to N do gu:=MCGdetail(n,x^2+x*y+y^2,x,y): MCGdetailV(n,x^2+x*y+y^2,x,y): print(``): print(`------------------------------------------`): print(``): print(`In a torunament with`, n, `players `): if nops(gu[2])>1 then print(`The set of champion score vectors is`, gu[2]): else print(`The sole champion score-vector is`, gu[2][1]): fi: print(`the corresponding record is`, gu[1]): mu:=[op(mu),gu[1]]: od: print(``): print(`------------------------------------------`): print(``): print(`In conclusion, the n=2 thorough n=`, N, `of the champions are `): print(``): lprint(mu): print(``): print(`------------------------------------------`): print(``): print(`This ends this article, that took`, time(), `seconds to produce. `): end: #PercySoccer(N): inputs a positive integer N and outputs an article about all the possible score vectors #in a round-robin Soccer Tournament with N players. #Try: #PercySoccer(6); PercySoccer:=proc(N) local n,gu,mu,x,y: print(`All the Possible Score Vectors in a Round-Robin Soccer Tournament, and the Number of Times each Shows Up`): print(`for tournaments from Three to `, N, `players. `): print(``): print(`By Shalosh B. Ekhad`): print(``): print(`In his beautiful articles, "An American Tournament Treated by the Calculus of Symmetric Functions"`): print(` Quarterly J. of Pure and Applied Mathematics. vol. XLIX, No. 193, 1920 and`): print(`"Chess Tournament and the like treated by the calculus of Symmetric Functions"`): print(` Quarterly J. of Pure and Applied Mathematics. vol. 49 (1923), 353-384`): print(`The Combinatorial Giant, (and amazing human calculator), Major Percy Alexander MacMahon`): print(`considered round-robin Tennis and Chess tournaments, respectively, for n players for n up to 9 and 6 respectively, and for each found all the`): print(`possible score vectors and for each their number of occurrences.`): print(``): print(`In this article, we do the analogous thing for Soccer for tournments up to`, N, `players. `): print(``): print(`Recall that in a Soccer match with a winner, the winner gets three point, and the loser gets 0 points, and in case of`): print(`a draw, each gets one point.`): print(``): mu:=[]: for n from 3 to N do gu:=MCGdetail(n,x^3+x*y+y^3,x,y): MCGdetailV(n,x^3+x*y+y^3,x,y): print(``): print(`------------------------------------------`): print(``): print(`In a torunament with`, n, `players `): if nops(gu[2])>1 then print(`The set of champion score vectors is`, gu[2]): else print(`The sole champion score-vector is`, gu[2][1]): fi: print(`the corresponding record is`, gu[1]): mu:=[op(mu),gu[1]]: od: print(``): print(`------------------------------------------`): print(``): print(`In conclusion, the n=2 thorough n=`, N, `of the champions are `): print(``): lprint(mu): print(``): print(`------------------------------------------`): print(``): print(`This ends this article, that took`, time(), `seconds to produce. `): end: #GGF(n,W,L,P,G): inputs a positive integer n, and symbols W,L,P, outputs a rational function in the #3*n variables, W[1], ..., W[n], L[1], ..., L[n], P[1], ..., P[n] whose coefficient of #W[1]^w[1]*...*W[n]^w[n]*L[1]^l[1]*...*L[n]^l[n]**P[1]^p[1]*...*P[n]^p[n]*G^g is the number of ways #in a round-robin Soccer tournament with n teams, #team i had w[i] Goals For, l[i] Goals Against, and p[i] points (where a win gets you three points, a loss nothing, and a draw one point). #and total of G goals #Try: #GGF(3,W,L,P,G); GGF:=proc(n,W,L,P,G) local i,j: mul( mul( P[i]^3*W[i]*L[j]*G/(1-W[i]*L[j]*G)/(1-W[i]*L[j]*W[j]*L[i]*G^2) +P[j]^3*W[j]*L[i]*G/(1-W[j]*L[i]*G)/(1-W[j]*L[i]*W[i]*L[j]*G^2)+ P[i]*P[j]/(1-W[i]*L[i]*W[j]*L[j]*G^2), i=1..j-1),j=1..n): end: #GGGF(n,W,L,P,G): inputs a positive integer n, and symbols W,L,P, outputs a rational function in the #3*n variables, W[1], ..., W[n], L[1], ..., L[n], P[1], ..., P[n] whose coefficient of #W[1]^w[1]*...*W[n]^w[n]*L[1]^l[1]*...*L[n]^l[n]**P[1]^p[1]*...*P[n]^p[n]*G^g is the generating polynomial #of the actual matches expressed in terms of W[i,j], W[j,i] of ways #in a round-robin Soccer tournament with n teams, #team i had w[i] Goals For, l[i] Goals Against, and p[i] points (where a win gets you three points, a loss nothing, and a draw one point). #and total of G goals #Try: #GGGF(3,W,L,P,G); GGGF:=proc(n,W,L,P,G) local i,j: mul( mul( P[i]^3*W[i]*L[j]*G*W[i,j]/(1-W[i]*L[j]*W[i,j]*G)/(1-W[i]*L[j]*W[j]*L[i]*W[i,j]*W[j,i]*G^2) +P[j]^3*W[j]*L[i]*W[j,i]*G/(1-W[j]*L[i]*G*W[j,i])/(1-W[j]*L[i]*W[i]*L[j]*W[i,j]*W[j,i]*G^2)+ P[i]*P[j]/(1-W[i]*L[i]*W[j]*L[j]*W[i,j]*W[j,i]*G^2), i=1..j-1),j=1..n): end: