#Homework 19 by Ben Miles for Experimental math OK to post WnX:=proc(A,FP,B,n,x) option remember: WGnX(A,FP,B,n,{},x); end: WGnX:=proc(A,FP,B,n,BFP,x) local co,a,BFP1: option remember: if member([],BFP union FP) then RETURN(0): fi: if n=0 then RETURN(1): fi: co:=0: for a in A do BFP1:=AdjustBFP(a,B,FP,BFP): co:=co+x[a]*WGnX(A,FP,B,n-1,BFP1,x): od: co: end: ########old stuff #C19.txt Help:=proc(): print(`Adn(d,n), IsBad(d,S),adnS(d,n)`): print(`NdnS(d,n) , AdnM(d,n), adnM(d,n), NdnM(d,n) `): print(`AdjustBFP(a,B,FP,BFP) , Wn(A,FP,B,n), WGn(A,FP,B,n,BFP)`): end: #Dedicated to Endre Szemeredi on the occaison of the Abel Prize 2012 with(combinat): #Let a_d(n) be the largest size of a subset of {1, ...,n} #avoiding arthmetical pogressions of length d #(Szemeredi's famous theorem says that a_d(n)/n->0) #d=3 is it the already deep Roth theorem who proved that #a_3(n)/n<=C/log(log(n)) #Adn(d,n): Inputs positive integers d and n and outputs #the set of all subsets of {1, ...,n} that DO NOT have #an arithmetical progression of length d Adn:=proc(d,n) local S,s1,i,T: S:=powerset(n): T:={}: for s1 in S do if not IsBad(d,s1) then #T:=T union {s1}: T:={op(T), s1}: fi: od: T: end: #IsBad(d,S): Does the set of pos. integers S contain #an AP of length d? IsBad:=proc(d,S) local m,S1,dif,PTM,j: option remember: if nops(S)