#copyright 1998 by A. Robertson and D. Zeilberger print(`Version of March 25, 1998`): lprint(``): print(`This is RON, A Maple package accompanying `): print(`Aaron Robertrson and Doron Zeilberger's article`): print(`"A 2-Coloring of [1,n] can have (1/22)n^2 + O(n)`): print(`monochromatic triples, but not less!"`): 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(`100 dollars problem about finding`): print(`katan(n):=the max of schur(a) over all 0-1 vectors of length n`): print(`where schur(a) is the number of Schur triples: 1<=i=0 that`): print(`decide whether this term has to be added to Ron(resh):`): print(`For example, try Ronresh([a]),Ronresh([a,b]`): fi: if nops([args])=1 and op(1,[args])=findpol then print(`findpol(f,a,a0,L,Maxdeg) finds emprically the polynomial of`): print(` degree <=Maxdeg that fits the function f`): print(` in the variable a near a=a0 with resolution L`): print(`if it fails, it returns 0`): fi: if nops([args])=1 and op(1,[args])=findpol2 then print(`findpol2(f,a,b,a0,b0,L,Maxdeg) finds emprically the polynomial of`): print(` degree <=Maxdeg that fits the function f`): print(` in the variable a near a=a0 with resolution L`): print(`if it fails, it returns 0`): fi: if nops([args])=1 and op(1,[args])=katan then print(`katan(n) finds the smallest possible number of Schur triples`): print(`that a 0-1 vector of length n can have`): fi: if nops([args])=1 and op(1,[args])=bdok then print(`bdok(resh,L) checks the validity of Ron empirically by`): print(`comparing it with (Br(n*resh)) for L from 20 to L`): fi: if nops([args])=1 and op(1,[args])=f2 then print(`f2(a,b) gives Ron([a,b]) in terms of the exact`): print(`formula outputted by Ronresh, after it was cleaned up`): fi: if nops([args])=1 and op(1,[args])=hakhi1 then print(`hakhi1(L) finds the input that minimizes Ron([x]), and the`): print(`corresponding value, in resolutions of 1/L`): fi: if nops([args])=1 and op(1,[args])=hakhi2 then print(`hakhi2(L) finds the input that minimizes Ron([x,y]), x=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) 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): if pu=gu then gu:=pu: lu:=lu union {ku}: fi: if pu=2*b then RETURN(0): fi: #Case II if a+b<=c and c<2*b then gu:=(2*b-c)^2/4: if 2*b-d>=0 then gu:=gu-(2*b-d)^2/4: fi: RETURN(gu): fi: #case III if 2*a<=c and c=2*b then RETURN((b-a)^2/2-(c-2*a)^2/4): fi: #case III.2 if a+b<=d and d<2*b then RETURN((b-a)^2/2-(c-2*a)^2/4-(2*b-d)^2/4): fi: #case III.3 if 2*a<=d and db+d then RETURN((b-a)*(d-c)-(e-a-c)^2/2 ): fi: #endcase I2 fi: #case I3 if a+db+d then RETURN((b-a)*(d-c)- (d-c)/2*((e-d-a)+(e-c-a)) ): fi: #endcase I3 fi: #case I4 if b+cb+d then RETURN((b-a)*(d-c)-(e-a-c)^2/2 ): fi: #endcase II2 fi: #case II3 if b+cb+d then RETURN((b-a)*(d-c)- (b-a)/2*((e-b-c)+(e-a-c)) ): fi: #endcase II3 fi: #case II4 if a+d<=e and e=20`): fi: m:=nops(resh): gu:=RON(resh): for n from L to L do mu:=[seq(0,i=1..trunc(op(1,resh)*n))]: for k from 1 by 2 to m-2 do mu:=[op(mu),seq(1,i=trunc(op(k,resh)*n)+1..trunc(op(k+1,resh)*n))]: mu:=[op(mu),seq(0,i=trunc(op(k+1,resh)*n)+1..trunc(op(k+2,resh)*n))]: od: if m mod 2 =0 then mu:=[op(mu),seq(1,i=trunc(op(m-1,resh)*n)+1..trunc(op(m,resh)*n))]: mu:=[op(mu),seq(0,i=trunc(op(m,resh)*n)+1..n)]: else mu:=[op(mu),seq(1,i=trunc(op(m,resh)*n)+1..n)]: fi: print(evalf(schur(mu)/n^2)): od: print(`Ron(`,resh,`)=`,Ron(resh)): end: ################################################### hakhim1:=proc(L,K) local i,gu,mu,aluf,alufy,k: aluf:=0: gu:=1: for i from 1 to L-1 do mu:=Ron([i/L]): if mu=5`): fi: aluf:=[]: gu:=1: for i from 1 to L-4 do for j from i+1 to L-3 do for j1 from j+1 to L-2 do for j2 from j1+1 to L-1 do mu:=Ron([i/L,j/L,j1/L,j2/L]): if mu=0 and b>=a and b<=1) then ERROR(`Wrong input`): fi: if a>=1/2 then 1/4-b+3/4*b^2+a-a*b+1/4*a^2: elif b<=1/2 then 1/4-b+5/4*b^2+a-2*a*b+3/4*a^2: elif a<=1/2 and 1/2<=b and b<=1-a then 1/4*b^2+a-2*a*b+3/4*a^2: elif a+b>=1 and a<=1/2 then 1/2-b+3/4*b^2-a*b+5/4*a^2: else ERROR(`Too bad`): fi: end: ################################################## #Ronresh gives Ron as an algebraic expression in its arguments #in a more convenient form for later processing, i.e. #it is given as a set of contribution, each of which is #a list of length 2 of the form [expr,set of linear expressions] #where the linear expressions describe the inequalities >=0 that #decide whether this term has to be added to Ron(resh): Ronresh1:=proc(resh) local kakpap,Efes, Ekhad,n,gu,mu,i,j,k,mu1,mu2: n:=nops(resh): Efes:=[[0,op(1,resh)]]: Ekhad:=[]: for i from 2 by 2 to nops(resh)-1 do Efes:=[op(Efes),[op(i,resh),op(i+1,resh)]]: od: if n mod 2=0 then Efes:=[op(Efes),[op(n,resh),1]]: fi: for i from 1 by 2 to nops(resh)-1 do Ekhad:=[op(Ekhad),[op(i,resh),op(i+1,resh)]]: od: if n mod 2=1 then Ekhad:=[op(Ekhad),[op(n,resh),1]]: fi: gu:=[]: for i from 1 to nops(Efes) do mu:=op(i,Efes): gu:=[op(gu),op(F111(op(1,mu),op(2,mu)))]: od: for i from 1 to nops(Efes) do mu:=op(i,Efes): for j from i+1 to nops(Efes) do mu1:=op(j,Efes): kakpap:=F112(op(1,mu),op(2,mu),op(1,mu1),op(2,mu1)): gu:=[op(gu),op(kakpap)]: kakpap:=F122(op(1,mu),op(2,mu),op(1,mu1),op(2,mu1)): gu:=[op(gu),op(kakpap)]: od: od: for i from 1 to nops(Efes) do mu:=op(i,Efes): for j from i+1 to nops(Efes) do mu1:=op(j,Efes): for k from j+1 to nops(Efes) do mu2:=op(k,Efes): kakpap:=F123(op(1,mu),op(2,mu),op(1,mu1),op(2,mu1), op(1,mu2),op(2,mu2)): gu:=[op(gu),op(kakpap)]: od: od: od: for i from 1 to nops(Ekhad) do mu:=op(i,Ekhad): kakpap:=F111(op(1,mu),op(2,mu)): gu:=[op(gu),op(kakpap)]: od: for i from 1 to nops(Ekhad) do mu:=op(i,Ekhad): for j from i+1 to nops(Ekhad) do mu1:=op(j,Ekhad): kakpap:=F112(op(1,mu),op(2,mu),op(1,mu1),op(2,mu1)): gu:=[op(gu),op(kakpap)]: kakpap:= F122(op(1,mu),op(2,mu),op(1,mu1),op(2,mu1)): gu:=[op(gu),op(kakpap)]: od: od: for i from 1 to nops(Ekhad) do mu:=op(i,Ekhad): for j from i+1 to nops(Ekhad) do mu1:=op(j,Ekhad): for k from j+1 to nops(Ekhad) do mu2:=op(k,Ekhad): kakpap:=F123(op(1,mu),op(2,mu),op(1,mu1),op(2,mu1), op(1,mu2),op(2,mu2)): gu:=[op(gu),op(kakpap)]: od: od: od: gu: end: ################################################# #F111(a,b) finds the number of triples (i,j,i+j) s.t. a<=i=1/10^10}: od: feasible(kvu2,NONNEGATIVE): end: ################################################## dif:=proc(n,r) local gu,i: gu:=0: for i from 1 to n do gu:=gu+x[i]: od: for i from 1 to n-r do gu:=gu+x[i]: od: gu:=gu- (n-2-trunc(r/2)+H(2*r-n-1))-x[r]: if r mod 2 =0 then gu:=gu-x[r/2]: fi: if 2*r<=n then gu:=gu-x[r]-x[2*r]: fi: gu: end: ################################################ H:=proc(a): if a>=0 then 1: else 0: fi: end: ############################################### F:=proc(n) local i,j,gu: gu:=0: for i from 1 to n do for j from i+1 to n-i do gu:=gu+x[i]*x[j]*x[i+j]+ (1-x[i])*(1-x[j])*(1-x[i+j]): od: od: gu: end: ################################################## diff1:=proc(n,r): sort(factor(F(n)-subs(x[r]=1-x[r],F(n)))/(2*x[r]-1)): end: ################################################## Diff1:=proc(F,r): expand(F-subs(x[r]=1-x[r],F)): end: ################################################## g:=proc(n,r) local i,gu: gu:=0: for i from 1 to n do gu:=gu+x[i]: od: for i from 1 to n-r do gu:=gu+x[i]: od: gu:=gu-n+r/2: (x[r]-(1-x[r]))*gu: end: ################################################ kapi:=proc(x) local gu,mu,n,k,r: gu:=[]: n:=nops(x): mu:=convert(x,`+`): k:=mu: gu:=[]: for r from 0 to n-1 do gu:=[op(gu),k-n+r/2+mu]: mu:=mu-op(n-r,x): od: gu: end: ############################################### Fan2:=proc(x) if x>=1 then RETURN(0): else RETURN(1): fi: end: ################################################# Fan3:=proc(x) if x>=1/2 then RETURN(0): else RETURN(1): fi: end: ################################################## checkptor:=proc(x,n,k) local r,j,lu1,lu2: lu1:=[]: for r from 1 to n do lu1:=[op(lu1),sign(-1/2^20+(2*x[r]-1)*(2*k-n+r/2 -convert([op(n-r+1..n,x)],`+`)))]: od: lu2:=[]: for r from 1 to n do lu2:=[op(lu2),sign(-1/2^20+(2*x[r]-1)*(k-n+r/2 +convert([op(1..n-r,x)],`+`)))]: od: lu2,lu1: end: ################################################# ptor:=proc(n,k) local x,r,j: for r from n to trunc((n+1)/2)+1 by -1 do x[r]:=Fan3(k-n+trunc(r/2)+ convert([seq(x[j],j=1..n-r)],`+`) ): x[n-r+1]:=Fan2(2*k-n-1/2+trunc((n-r+1)/2)-convert([seq(x[j],j=r..n)],`+`) ): od: if n mod 2=1 then r:=trunc(n/2): x[n-r]:=Fan3(k-n+trunc((n-r)/2)+ convert([seq(x[j],j=1..r)],`+`)): fi: [seq(x[r],r=1..n)]: end: ################################################ kama:=proc(x,r) local i: for i from 1 to nops(x) while x[i]=r do od: i-1: end: ################################################# tsamek:=proc(x) local nu,i,lu,x1,mi: nu:=nops(x): lu:=[]: x1:=x: while x1<>[] do mi:=kama(x1,0): lu:=[op(lu),mi]: x1:=[op(mi+1..nops(x1),x1)]: mi:=kama(x1,1): lu:=[op(lu),mi]: x1:=[op(mi+1..nops(x1),x1)]: od: if op(nops(lu),lu)=0 then lu:=[op(1..nops(lu)-1,lu)]: fi: lu: end: #################################################