#copyright 1998 by A. Robertson and D. Zeilberger print(`Version of September 25, 1998`): lprint(``): print(`This is GENRON, A Maple package accompanying `): print(`written by Aaron Robertson and Doron Zeilberger`): print(` The lastest version of this package and of the article`): print(` are available from http://www.math.temple.edu/~zeilberg`): print(` and http://www.math.temple.edu/~aaron`): lprint(``): print(`Please report all bugs to: zeilberg@math.temple.edu .`): print(`or aaron@math.temple.edu .`): print(`All bugs or other comments used will be acknowledged in future`): print(`versions.`): lprint(``): print(`For general help, and a list of the available functions,`): print(` type "ezra();". For specific help type "ezra(procedure_name)" `): lprint(``): with(simplex): ezra:=proc() if args=NULL then print(`This is RON, A Maple package to investigate Ron Graham's`): print(`problem about finding`): print(`the number of monochromatic solns of x+ay=z`): lprint(``): print(`Contains the procedures:`): print(`katan, schur, B, and Ron`): fi: if nops([args])=1 and op(1,[args])=katan then print(`katan(n,m) finds the smallest possible number of`): print(`monochromatic solutions of x+my=z`): print(`that a 0-1 vector of length n can have`): fi: if nops([args])=1 and op(1,[args])=Ron then print(`Ron(list,m) finds the asymptotics of schur(a,m)/n^2,`): print(`when n goes to infinity`): print(`where a is [0^(list[1]*n),1^((list[2]-list[1])*n), ...,]`): print(`where list[n+1] is 1`): print(`For example to find the limit of`): print(` schur([0^{4/11*n},1^{6/11*n},0^{1/11*n}])/n^2,1),type`): print( ` Ron([4,11,10/11],1) `): fi: if nops([args])=1 and op(1,[args])=B then print(`B(list,m) finds the number of monochromatic`): print(`solutions of x+my=z`): print(`of the vector [0^list[1],1^list[2],0^list[3], ...]`): fi: if nops([args])=1 and op(1,[args])=schur then print(`schur(a,m) finds the number of monochromatic`): print(`solutions in the 0-1 vector a.`): print(`In other words: the number of 1<=i=0`): fi: mu:=vects(n-1): gu:={}: for i from 1 to nops(mu) do gu:=gu union {[op(op(i,mu)),0],[op(op(i,mu)),1]}: od: gu: end: ################################################## katan:=proc(n,m) local i,pu,ku,lu,gu,mu: gu:=n^2: mu:=vects(n): lu:={}: for i from 1 to nops(mu) do ku:=op(i,mu): pu:=schur(ku,m): if pu=gu then gu:=pu: lu:=lu union {ku}: fi: if pu=(m+1)*b then RETURN(0): fi: #Case II if a+m*b<=c and c<(m+1)*b then gu:=((m+1)*b-c)^2 / (2*m*(m+1)): if (m+1)*b-d>=0 then gu:=gu-((m+1)*b-d)^2 / (2*m*(m+1)): fi: RETURN(gu): fi: #case III if (m+1)*a<=c and c=(m+1)*b then RETURN((b-a)^2/2-(c-(m+1)*a)^2 / (2*m*(m+1))): fi: #case III.2 if a+m*b<=d and d<(m+1)*b then RETURN((b-a)^2/2-(c-(m+1)*a)^2 / (2*m*(m+1)) - ((m+1)*b-d)^2 / (2*m*(m+1))): fi: #case III.3 if (m+1)*a<=d and db+m*d then RETURN((b-a)*(d-c)-(e-a-m*c)^2/2 ): fi: #endcase I2 fi: #case I3 if a+m*db+m*d then RETURN((b-a)*(d-c)- (d-c)/2*((e-m*d-a)+(e-m*c-a)) ): fi: #endcase I3 fi: #case I4 if b+m*cb+m*d then RETURN((b-a)*(d-c)-(e-a-m*c)^2/2 ): fi: #endcase II2 fi: #case II3 if b+m*cb+m*d then RETURN((b-a)*(d-c)- (b-a)/2*((e-b-m*c)+(e-a-m*c)) ): fi: #endcase II3 fi: #case II4 if a+m*d<=e and enops(y) then RETURN(`The lengths of the two lists must be equal.`): fi: n:=nops(x): gu:=0: for i from 1 to n/(m+1) do for j from i+1 to (n-i)/(m+1) do k:=i+m*j: gu:=gu+x[i]*(2*y[j]-x[j])+x[j]*(2*y[i]-x[j])+x[k]*(2*y[i]-x[i]) + y[k]*(2*x[i]-y[i]) - x[k]*(2*x[j]-y[j]) - y[k]*(2*y[j]-x[j]) + 2*(x[j]+y[j]): od: od: gu: end: