###################################################################### ## Volker.txt Save this file as Volker.txt to use it, # # stay in the # ## same directory, get into Maple (by typing: maple ) # ## and then type: read `Volker.txt` # ## Then follow the instructions given there # ## # ## Written by Pablo Blanco and # #Doron Zeilberger, Rutgers University , # ###################################################################### print(`First Written: Jan. 2026: tested for Maple 2020 `): print(`Version of March 20, 2026`): with(combinat): with(plots): print(): print(`This is Volker.txt, A Maple package`): print(`To enumerate and experiment with Hamlitonian cycles in a grid graph`): print(``): print(`It is one of the Maple packages that accompanies the article : Counting (and Randomly Generating) Hamiltonians Cycles in Rectangular Grids `): print(``): print(`By Pablo Blanco and Doron Zeilberger`): print(): print(`The most current version is available from:`): print(` http://sites.math.rutgers.edu/~zeilberg/tokhniot/Volker.txt .`): print(`Please report all bugs to: DoronZeil at gmail dot com .`): print(): print(`-----------------------------`): print(`For general help, and a list of the MAIN functions,`): print(` type "ezra();". For specific help type "ezra(procedure_name);" `): print(): print(`-----------------------------`): print(`For a list of the supporting procedures type ezra1()`): print(`For specific help type "ezra(procedure_name);" `): print(): print(`-----------------------------`): print(`-----------------------------`): print(`For a list of the Empirical procedures type ezraE()`): print(`For specific help type "ezra(procedure_name);" `): print(): print(`For a list of the Asymptotics procedures type ezraA()`): print(`For specific help type "ezra(procedure_name);" `): print(`-----------------------------`): print(`For a list of the Paper procedures type ezraP()`): print(`For specific help type "ezra(procedure_name);" `): print(): print(`-----------------------------`): print(`-----------------------------`): ezraA:=proc() if args=NULL then print(`The asymptotics procedures are: Asy1E, Asy1N, AsyAve, AsyVar, AsyCov, AsyCor `): print(` `): else ezra(args): fi: end: ezraP:=proc() if args=NULL then print(`The paper procedures are: Paper1, Paper2, Paper3, Paper4, Paper5 `): print(` `): else ezra(args): fi: end: ezraE:=proc() if args=NULL then print(`The Empirical procedures are: EmpAlp1, EmpAlp, FollowersE, FollowersEt, GFnzE `): print(` `): else ezra(args): fi: end: ezra1:=proc() if args=NULL then print(`The SUPPORTING procedures are: AllMatsF1, AllWords, AllWords1, AreComp, AreNeis, ConTable, Enders, Extr1, FindOneMore, FindOnes, Followers, FollowersM, GG, GtoN, `): print(`HasCycle, HasCycle1, HasCycle2, IndSP, IsForest, IsGoodMat, IsMate, IsTree, Paths1, PickSE, OneGraph, Starters, Stat, SumCol, Vecs, VecToSP1 `): print(` `): else ezra(args): fi: end: ezra:=proc() if args=NULL then print(`The main procedures are: AllMats, AllMatsF, AlphaSS, AntiFindMatrix, CheckRandHP, FindMatrix, GFnz, GFnzG, GFnzPC, HP, MatToW, PlotC, PlotHP, PlotP, RandHP, SSdg `): print(` `): elif nargs=1 and args[1]=AllMats then print(`AllMats(m,n): all the matrices corresponding to HP(GG(m,n),[1,1],[1,2]). Try:`): print(`AllMats(4,6);`): elif nargs=1 and args[1]=AllMatsF then print(`AllMatsF(m,n): Same as AllMats(m,n), but via the Stoyan-Strehl approach, using Dynamical programming. Try: `): print(`AllMatsF(4,6);`): elif nargs=1 and args[1]=AllMatsF1 then print(`AllMatsF1(m,n): All (n-1)x(m-1) matrices such that the ones form a forest. A superset of AllMats(m,n), but done faster. Try:`): print(`AllMatsF1(4,6);`): elif nargs=1 and args[1]=AllWords then print(`AllWords(m,n):The mapping of AllMats(m,n). Try:`): print(`AllWords(4,4);`): elif nargs=1 and args[1]=AllWords1 then print(`AllWords1(m,n):The superset of AllMats(m,n) that contains all prefixes of AllWords(m,n). Try:`): print(`AllWords1(4,4);`): elif nargs=1 and args[1]=AlphaSS then print(`AlphaSS(n): All the letters in the Stoyan-Strehl alphabet of length n. Try:`): print(`AlphaSS(3);`): elif nargs=1 and args[1]=AreComp then print(`AreComp(u,v), are the 0-1 vectors u and v compatible in the sense of Stoyan-Strehl? Try:`): print(`AreComp([0,1],[1,1]);`): elif nargs=1 and args[1]=AreNeis then print(`AreNeis(pt1,pt2,C): given two lattice points in the dual graph of cells (given by their leftmost-bottom corner and a Hamiltonian cycle decides whether they`): print(`are both inside or both outside C. Try:`): print(`C:=HP(GG(4,4),[1,1],[1,2])[1]: AreNeis([2,2],[2,3],C);`): elif nargs=1 and args[1]=Asy1E then print(`Asy1E(f,z): Given a rational function f whose denominator has no multiple roots, finds [C,alpha] such that`): print(`the coeff. of z^n is C*alpha^n. DONE EXACTLY. Try:`): print(`Asy1E((z^2+1)/(1-z-z^2),z);`): elif nargs=1 and args[1]=Asy1N then print(`Asy1N(f,z): Given a rational function f whose denominator has no multiple roots, finds [C,alpha] such that`): print(`the coeff. of z^n is C*alpha^n. DONE NUMERICALLY.. Try:`): print(`Asy1N((z^2+1)/(1-z-z^2),z);`): elif nargs=1 and args[1]=AsyAve then print(`AsyAve(f,z,w,K): inputs a rational function f in z and w estiamtes [C1,C0] such that the coeff. of z^n of subs(w=1,diff(f,w)) divided by the coeff. of z^n equals C1*n+C0 by looking`): print(`at two consectutive terms around the coeff. of z^K. Try:`): print(`AsyAve((z^2+1)/(1-w*z-z^2),z,w,2000);`): elif nargs=1 and args[1]=AsyCov then print(`AsyCov(f,z,w1,w2,K): inputs a rational function f in z, w1 and w2, where the coeff.of z^n is the bi-variate weight-enumerator of some bi-statistic defined on the combinatorial set A_n (in the combinatorial family)`): print(`outputs [C1,C2] such that the covariance is asymptotically is C1*n+C2`): print(`AsyCov(1/(1-z*w1-w2*z^2),z,w1,w2,500);`): elif nargs=1 and args[1]=AsyCor then print(`AsyCor(f,z,w1,w2,K): inputs a rational function f in z, w1 and w2, where the coeff.of z^n is the bi-variate weight-enumerator of some bi-statistic defined on the combinatorial set A_n (in the combinatorial family)`): print(`outputs the limit of the coeff. of correlation. Try:`): print(`AsyCor(1/(1-z*w1-w2*z^2),z,w1,w2,500);`): elif nargs=1 and args[1]=AsyVar then print(`AsyVar(f,z,w,K): inputs a rational function f in z and w estiamtes [C1,C0] such that the variance of the polynomial in w that is the coeff. of z^n in the Maclaurin expansion of f, equals C1*n+C0 by looking`): print(`AsyVar((z^2+1)/(1-w*z-z^2),z,w,2000);`): elif nargs=1 and args[1]=CheckRandHP then print(`CheckRandHP(m,n,c,K,K1): Checks RandHP(m,n) by comparing the empirical statistics to the exact one regarding the`): print(`number of 1's in the associated Stoyan-Strehl 0-1 matrix (number of cells contained INSIDE the circuit)`): print(`in the c-th column. It compares the empirical average, standad-deviation and the scaled moments up to the K1. Try:`): print(`CheckRandHP(4,20,1,100,4);`): elif nargs=1 and args[1]=ConTable then print(`ConTable(SP1,SP2): inputs a set parition SP1 and a virgin set partition SP2, outputs a table`): print(`defined on the members of SP2 indicationg the set of members of SP1 it intersects with it.`): print(`Try: ConTable({{1,2,3,9},{5,6,7}}, {{3,4,5},{7,8,9}});`): elif nargs=1 and args[1]=EmpAlp1 then print(`EmpAlp1(m,n): The first letters, all letters, and final letters of words in AllMats(n,m). Try:`): print(`EmpAlp1(4,6);`): elif nargs=1 and args[1]=EmpAlp then print(`EmpAlp(m): The first letters, all letters, and final letters of words in AllMats(m,n) for sufficiently large n. Try:`): print(`EmpAlp(4);`): elif nargs=1 and args[1]=Enders then print(`Enders(n): All the possible ending letters of binary vectors of length n. Try:`): print(`Enders(4);`): elif nargs=1 and args[1]=Extr1 then print(`Extr1(L,S): Given a list L and a set,S, of members of L outputs the sublist of L consisting of S. Try:`): print(`Extr1([1,4,3,5,2,6],{2,4});`): elif nargs=1 and args[1]=FindMatrix then print(`FindMatrix(m,n,C): Inputs positive integers m and n and a Hamiltonian cycle C of [1,m]x[1,n] outputs the corresponding (m-1)x(n-1) 0-1 matrix according to`): print(`Stoyan and Strehl. Try:`): print(`C:=HP(GG(4,3),[1,1],[1,2])[1]: FindMatrix(4,3,C);`): elif nargs=1 and args[1]=FindOneMore then print(`FindOneMore(m,n,C,S): Given a Hamiltonian cycle C of [1,m]x[1,n] starting at [1,1] and ending in [1,2] finds`): print(`and currently a set of cells inside the cycle, tries to find one more`): print(`or else returns FAIL. Try:`): print(`C:=HP(GG(4,3),[1,1],[1,2])[1]: FindOneMore(4,3,C,{[1,1]});`): elif nargs=1 and args[1]=FindOnes then print(`FindOnes(m,n,C): Given positive integers m and n and a Hamiltonian cycle,C, in [1,m]x[1,n] finds all the cells inside C,`): print(`Try: `): print(`C:=HP(GG(4,3),[1,1],[1,2])[1]: FindOnes(4,3,C);`): elif nargs=1 and args[1]=Followers then print(`Followers(W1): Inputs a letter in the Stoyan-Strehl alphabet, outputs all the followers. Try:`): print(`Followers([[1,1,1],{{1,2,3}}]);`): elif nargs=1 and args[1]=FollowersE then print(`FollowersE(W1): Inputs a letter in the Stoyan-Strehl alphabet, outputs all the followers, done empirically. Try:`): print(`FollowersE([[1,1,1],{{1,2,3}}]);`): elif nargs=1 and args[1]=FollowersEt then print(`FollowersEt(n,m): The follower table for EmpAlp(n) does empirically. Try:`): print(`FollowersEt(3,6);`): elif nargs=1 and args[1]=FollowersM then print(`FollowersM(M): Given a 0-1 matrix M finds all the legal followers . Try:`): print(`FollowersM([[1,0,1]]);`): elif nargs=1 and args[1]=GFnz then print(`GFnz(n,z): The rational function whose coefficient of z^m is the number of Hamiltonian cycles in the grid graph [n]x[m]. Try:`): print(`For OEIS sequence A79 type`): print(`GFnz(3,z);`): print(`For OEIS sequence A6864 type`): print(`GFnz(4,z);`): print(`For OEIS sequence A6865 type`): print(`GFnz(5,z);`): print(`For OEIS sequence A145401 type`): print(`GFnz(6,z);`): print(`For OEIS sequence A145416 type`): print(`GFnz(7,z);`): print(`For OEIS sequence A145418 type`): print(`GFnz(8,z);`): print(`For OEIS sequence A160149 type`): print(`GFnz(9,z);`): elif nargs=1 and args[1]=GFnzG then print(`GFnzG(n,z,w): The rational function whose coefficient of z^m is the weight-enumerator ofthe set Hamiltonian cycles in the grid graph [n]x[m]. according to the`): print(`mul(w[i]^(NumberOf 1's in the i-th column, i=1..m) of the associated 0-1 matrix. Try:`): print(`GFnzG(3,z,w);`): elif nargs=1 and args[1]=GFnzPC then print(`GFnzPC(n,z): for n between 2 and 9, the pre-computed version of GFnz(n,z).`): print(`For OEIS sequence A79 type`): print(`GFnzPC(3,z);`): print(`For OEIS sequence A6864 type`): print(`GFnzPC(4,z);`): print(`For OEIS sequence A6865 type`): print(`GFnzPC(5,z);`): print(`For OEIS sequence A145401 type`): print(`GFnzPC(6,z);`): print(`For OEIS sequence A145416 type`): print(`GFnzPC(7,z);`): print(`For OEIS sequence A145418 type`): print(`GFnzPC(8,z);`): print(`For OEIS sequence A160149 type`): print(`GFnzPC(9,z);`): print(`For OEIS sequence A180504 type`): print(`GFnzPC(10,z);`): elif nargs=1 and args[1]=GFnzE then print(`GFnzE(n,z): The rational function whose coefficient of z^m is the number of Hamiltonian cycles in the grid graph [n+1]x[m+1], DONE EMPIRICALLT. Try:`): print(`GFnzE(3,z);`): elif nargs=1 and args[1]=GG then print(`GG(m,n): The grid-graph [0,m] x[0,n] . Try: `): print(`GG(4,6);`): elif nargs=1 and args[1]=GtoN then print(`GtoN(G): inputs a graph G=[V,E] and outputs [G,TableOfNeigbors]. Try:`): print(`GtoN([{1,2,3},{{1,2},{1,3}}]);`): elif nargs=1 and args[1]=HasCycle then print(`HasCycle(SP1,SP2): inputs a formet set partition SP1 and a virgin set parition SP2 finds out whether putting SP2 on top on SP1 formes a cycle. Try:`): print(`HasCycle({{1,3}},{{1,2,3}});`): elif nargs=1 and args[1]=HasCycle1 then print(`HasCycle1(SP1,SP2): inputs a formet set partition SP1 and a virgin set parition SP2 finds out whether putting SP2 on top on SP1 formes a cycle with ONE bridge. Try:`): print(`HasCycle({{1,3}},{{1,2,3}});`): elif nargs=1 and args[1]=HasCycle2 then print(`HasCycle2(SP1,SP2): inputs a formet set partition SP1 and a virgin`): print(`set parition SP2 finds out whether putting SP2 on top on SP1 formes a cycle with at least two bridges. Try:`): print(`HasCycle2({{1,2,3,10},{5,6,7}},{{2,3,4,5}, {7,8,9,10}});`): elif nargs=1 and args[1]=IndSP then print(`IndSP(SP1,SP2): Given two set-partitions SP1, SP2, makes SP2 possibly smaller by joining any two sets that intersect the same set in SP1. Try:`): print(`IndSP({{2,3,4},{6,7}},{{1,2},{4,5},{7,8,9}});`): elif nargs=1 and args[1]=IsForest then print(`IsForest(M): Given a 0-1 matrix M decides whether the set of 1's forms a forest. Try:`): print(`IsForest([[1,0,1],[1,0,1],[1,1,1]]);`): elif nargs=1 and args[1]=IsGoodMat then print(`IsGoodMat(M): Is the 0-1 matrix M good? Try:`): print(`IsGoodMat([[1,1,1,0,1],[0,0,1,0,1]]);`): elif nargs=1 and args[1]=IsMate then print(`IsMate(S1,S2,SP): is there a set in SP that intersects both S1 and S2? Try`): print(`IsMate({1,2,3},{5,6},[{3,4,5},{7,8}]);`): elif nargs=1 and args[1]=IsTree then print(`IsTree(M): Given a 0-1 matrix M decides whether the set of 1's forms a tree. Try:`): print(`IsTree([[1,0,1],[1,0,1],[1,1,1]]);`): elif nargs=1 and args[1]=HP then print(`HP(G,a,b): all the Hamiltonian paths from a to b in the graph G. Try:`): print(`HP(GG(5,5),[2,4],[3,3]);`): elif nargs=1 and args[1]=MatToW then print(`MatToW(M): Given a 0-1 matrix finds the corresponding word in the Stoyan-Strehl alphabet. Try: `): print(`gu:=AllMats(4,6); MatToW(gu[1]);`): elif nargs=1 and args[1]=OneGraph then print(`OneGraph(M): Given a 0-1 matrix M, outputs the graph formed by the 1's. The`): print(`output is the set of vertices followed by the set of edges [V,E]. Try:`): print(`OneGraph([[1,0,1],[1,0,0],[0,1,1]]);`): elif nargs=1 and args[1]=SumCol then print(`SumCol(M,j): Inputs a 0-1 matrix with nops(M[1]) columns, outputs the sum of the j-th column. Try:`): print(`SumCol([[a1,a2,a3],[b1,b2,b3]],2);`): elif nargs=1 and args[1]=Paper1 then print(`Paper1(M,N1,z): an article with the generating functions for enumerating the number of Hamiltonian cycles in grid graphs [n+1]x[m+1] for m from 2 to M`): print(`it also returns the first N1 terms. Try`): print(`Paper1(5,30,z);`): elif nargs=1 and args[1]=Paper2 then print(`Paper2(M,N1,z,w): an article with the generating functions in z, for weight-enumerating the set of Hamiltonian cycles in grid graphs [n+1]x[m+1] for m from 2 to M`): print(`Here the weight is regarding the associated m by n , 0-1 matrices, and the weight is mul(w[j]^NumberOfOnesInColum[j],j=1..m)`): print(`it also returns the first N1 terms. Try`): print(`Paper2(5,10,z,w);`): elif nargs=1 and args[1]=Paper3 then print(`Paper3(M,n1,K,K1): A paper listing CheckRandHP(m,n,c,K,K1) for picking a random Hamiltonian cycle of the grid graph [n]x[m] for all`): print(`m from 3 to M and all columns,c, from 1 to m-1. n must be even. Try:`): print(`Paper3(6,20,100,4);`): elif nargs=1 and args[1]=Paper4 then print(`Paper4(M,K,z,w): A paper listing the generating function for the weight-enumerator of the set of Hamiltonian cycles in [n]x[m] according to the number of edges in the left-most side of the grid`): print(`followed by numerical (but very precise) asymptotic expressions for the average and variance,`): print(`m from 3 to M. K is a parameter for the numerics, and should be at least 400.`): print(`Paper4(6,500,z,w);`): elif nargs=1 and args[1]=Paper5 then print(`Paper5(M,K): A paper listing the asymptotic correlation (as n goes to infinity) between the number of edges visited in the left border and right border of the grid [n]x[m]`): print(`also between the number of 1's in the associated Stoyan-Strehl 0-1 matrix in the first and second columns.`): print(`m from 3 to M. K is a parameter for the numerics, and should be at least 400. Try:`): print(`Paper5(6,500);`): elif nargs=1 and args[1]=PickSE then print(`PickSE(m,n,K): picks two vertices (S,E) in GG(m,n) such the set of Hamiltonian paths from S to E is non-empty. It tries K times. If it fails it returns FAIL. Try:`): print(`PickSE(5,5,20);`): elif nargs=1 and args[1]=PlotC then print(`PlotC(a,b,PA): plots the cycle PA `): print(`gu:=HP(GG(4,4),[1,1],[1,2]):PlotC(gu[1]); `): elif nargs=1 and args[1]=PlotHP then print(`PlotHP(a,b,PA): plots the Hamiltonian Path PA in the m by n grid. Try:`): print(`gu:=HP(GG(4,4),[1,1],[1,2]):PlotHP(4,4,gu[1]); `): elif nargs=1 and args[1]=PlotP then print(`PlotP(a,b,PA): plots the Path PA `): print(`gu:=HP(GG(4,4),[1,1],[1,2]):PlotP(gu[1]); `): elif nargs=1 and args[1]=RandHP then print(`RandHP(m,n): A random Hamiltonian path in the Grid-Graph [n]x[m]. Try:`): print(`RandHP(4,6);`): elif nargs=1 and args[1]=SSdg then print(`SSdg(m): The directed graph,G, corresponding to Hamiltonian cycles on [m]x[n] with a fixed m, using the Stoyan-Strehl approach`): print(`vertex 1 is the START denoted by 1, and vertex nops(G) is the END denoted by SizeOfAlphabet+2 and the actual alphabet is of size nops(G)-2 and coincides with AlphaSS(m)`): print(`It also outputs the dictionary. Try:`): print(`SSdg(3);`): elif nargs=1 and args[1]=Starters then print(`Starters(n): All the possible starting letters of binary vectors of length n. Try:`): print(`Starters(4);`): elif nargs=1 and args[1]=Stat then print(`Stat(F,t,K): Given a generating function F of t, for a r.v. `): print(` Finds the statistical information. Try:`): print(`Stat((1+t)^1000,t,6);`): elif nargs=1 and args[1]=VecToSP1 then print(`VecToSP1(u): Given a 0-1 vector finds the set of connected componets of the places where there 1's. Try:`): print(`VecToSP1([1,0,1,0]);`): elif nargs=1 and args[1]=AntiFindMatrix then print(`AntiFindMatrix(M): inputs a 0-1 matrix M and outputs the corresponding hamiltonian path in the grid graph.`): print(`NOTE: the output matches the format of the HP() procedure.`): print(`Try:`): print(`AntiFindMatrix([[1, 1, 1], [1, 0, 1]]);`): elif nargs=1 and args[1]=DisjtCycles then print(`DisjtCycles(M): inputs a 0-1 matrix M. Outputs the corresponding edge-set in the grid graph, which`): print(` will always be a disjoint collection of cycles. Try:`): print(`DisjtCycles([[1, 1, 1], [1, 0, 1]]);`): else print(`There is no such thing as`, args): fi: end: ####Start from WDG.txt with(Statistics): ezraW:=proc() if args=NULL then print(`The main procedures are: RandW `): print(` `): elif nargs=1 and args[1]=RandW then print(`RandW(G,s,e,k): inputs a directed graph G=[V,T] , where T is a table such that T[v] are the outgoing neighbors, and two vertices s,e, in V, picks, uniformly at random, a walk from s to e with k steps`): print(`such that each walk is equally likely. Try:`): print(`G:=RDG(5,1/2); Walks(G,1,2,3); RandW(G,1,2,3);`): else print(`There is no such thing as`, args): fi: end: #LC(p): A loaded coin. Try: #add(LC(1/3),i=1..300); LC:=proc(p) local a,b,x: if not (type(p,fraction) and p>0 and p<1) then RETURN(FAIL): fi: a:=numer(p): b:=denom(p): x:=rand(1..b)(): if x<=a then true: else false: fi: end: #RDG(n,p): A random directed graph on vertices {1, ...,n}. The output is a list of sets, E, such that #E[i] is the subset of {1, ...,n}, of those j, that have an edge from i to j #Try: #RDG(5,1/2); RDG:=proc(n,p) local E,v,S,i: E:=[]: for v from 1 to n do S:={}: for i from 1 to n do if LC(p) then S:=S union {i}: fi: od: E:=[op(E),S]: od: end: #Walks(G,s,e,k): The set of walks with k steps, in the directed graph G, that start at s, end at e. Try: #G:=RDG(5,1/2); Walks(G,1,2,3); Walks:=proc(G,s,e,k) local n,gu,Nei,lu,lu1: option remember: n:=nops(G): if not ( type(s,integer) and type(e, integer) and 1<=s and s<=n and 1<=e and e<=n and type(k, integer) and k>=0) then RETURN(FAIL): fi: if k=0 then if s=e then RETURN({[s]}); else RETURN({}); fi: fi: Nei:=G[s]: gu:={}: for n in Nei do lu:=Walks(G,n,e,k-1): gu:=gu union {seq([s,op(lu1)],lu1 in lu)}: od: gu: end: #NuWalks(G,s,e,k): The number of walks with k steps, in the directed graph G, that start at s, end at e. Try: #G:=RDG(5,1/2); NuWalks(G,1,2,3); NuWalks:=proc(G,s,e,k) local n: option remember: n:=nops(G): if not ( type(s,integer) and type(e, integer) and 1<=s and s<=n and 1<=e and e<=n and type(k, integer) and k>=0) then RETURN(FAIL): fi: if k=0 then if s=e then RETURN(1); else RETURN(0); fi: fi: add(NuWalks(G,n,e,k-1), n in G[s]): end: #RandW(G,s,e,k): inputs a directed graph G on our convention, where the vertices are called {1, ..., n} with n:=nops(G), and two vertices s,e, in V, picks, uniformly at random, a walk from s to e with k steps #such that each walk is equally likely. Try: #G:=RDG(5,1/2); Walks(G,1,2,3); RandW(G,1,2,3); RandW:=proc(G,s,e,k) local Nei,n,X,LD,su,i: n:=nops(G): if not ( type(s,integer) and type(e, integer) and 1<=s and s<=n and 1<=e and e<=n and type(k, integer) and k>=0) then RETURN(FAIL): fi: if k=0 then if s<>e then RETURN(FAIL): else RETURN([s]): fi: fi: Nei:=convert(G[s],list): LD:=[seq(NuWalks(G,Nei[i],e,k-1),i=1..nops(Nei))]: su:=convert(LD,`+`): LD:=[seq(LD[i]/su,i=1..nops(LD))]: X:=RandomVariable(ProbabilityTable(LD)); n:=Nei[trunc(Sample(X,1)[1])]: [s,op(RandW(G,n,e,k-1))]: end: #AdjMat(G): Given a directed graph G in our format n:=nops(G). Outputs the n by n adjacency matrix #Try:G:=RDG(5,1/2);AdjMat(G); AdjMat:=proc(G) local M,M1,i,n,j: n:=nops(G): M:=[]: for i from 1 to n do M1:=[]: for j from 1 to n do if member(j, G[i]) then M1:=[op(M1),1]: else M1:=[op(M1),0]: fi: od: M:=[op(M),M1]: od: M: end: #WalkGF(G,x): Inputs a directed graph G=[V,T], where T[v] is the set of outgoing neighbors of v, and a variable x, outputs the matrix of rational functions whose (i,j) entry is #the generating function in x, according to lengths of walks from i to j. Try: #G:=RDG(5,1/2); WalkGF(G,x); WalkGF:=proc(G,x) local n,M,i: n:=nops(G): M:=AdjMat(G): M:=matrix([seq(expand([0$(i-1),1,0$(n-i)]-x*M[i]),i=1..n)]): normal(inverse(M)): end: ####end from WDG.txt ###start pre-computed data #GFnzPC(n,z): A pre-computed version of GFnz(n,z). If course much faster GFnzPC:=proc(n,z) local L: if not n>=3 and n<=9 then #print(`This will take a LONG time`): RETURN(GFnz(n,z)): fi: L:= [-z/(2*z^2-1), -z/(z^4-2*z^3+2*z^2+2*z-1), -z*(3*z^2+1)/(2*z^6+11*z^2-1), -z*(z ^12-2*z^11+4*z^10+9*z^9-15*z^8+3*z^7-3*z^5+24*z^4-24*z^3+3*z^2-z+1)/(2*z^14-4*z ^13+28*z^12+42*z^11-82*z^10-8*z^9+118*z^8-66*z^7-35*z^6+90*z^5+12*z^4-63*z^3+14 *z^2+5*z-1), -z*(96*z^32-48*z^30-4592*z^28-9162*z^26+64012*z^24-252197*z^22+ 643288*z^20-797154*z^18+453054*z^16-40229*z^14-111603*z^12+87046*z^10-33250*z^8 +6525*z^6-568*z^4+7*z^2+1)/(144*z^36+1728*z^34-5972*z^32+17732*z^30+92790*z^28-\ 178842*z^26-1036420*z^24+3390877*z^22-4008954*z^20+2681994*z^18-1690670*z^16+ 1251439*z^14-815141*z^12+386724*z^10-116734*z^8+20403*z^6-1932*z^4+85*z^2-1), z *(2*z^64+74*z^63-1783*z^62-5554*z^61+3068*z^60-17328*z^59-274486*z^58-1005136*z ^57-944944*z^56+2200412*z^55+4393029*z^54+4508256*z^53+15938854*z^52+13162292*z ^51-42380527*z^50-43622030*z^49-36881268*z^48+110093154*z^47+75291501*z^46-\ 84101040*z^45-276490810*z^44+113438464*z^43+306110646*z^42-261275234*z^41+ 663060588*z^40+490344896*z^39-3086017297*z^38-1095705448*z^37+5549491219*z^36+ 5171581220*z^35-9844952781*z^34-4486856598*z^33+12775242404*z^32-15888016092*z^ 31-1135195559*z^30+40947017226*z^29-22305149141*z^28-44848335674*z^27+ 36720403183*z^26+31571028176*z^25-36174767422*z^24-14435399066*z^23+26128986873 *z^22+1141503002*z^21-12326244453*z^20+2848593746*z^19+3377655817*z^18-\ 1834446618*z^17-182495382*z^16+389023844*z^15-159419927*z^14+53685844*z^13+ 14203168*z^12-30747404*z^11+9047953*z^10+3034428*z^9-1949741*z^8+66818*z^7+ 136279*z^6-22582*z^5-2309*z^4+728*z^3-49*z^2+8*z-1)/(36*z^66-532*z^65+6952*z^64 +34282*z^63-13629*z^62-103168*z^61+985598*z^60+4951334*z^59+4261277*z^58-\ 18129698*z^57-42867025*z^56-16408310*z^55+41238077*z^54+79877148*z^53+132682964 *z^52-27735814*z^51-380794039*z^50-143652474*z^49+1188567443*z^48-1646502104*z^ 47+1722204514*z^46-998576578*z^45-2669382577*z^44+4331661320*z^43-1463899423*z^ 42+4294619636*z^41-9600155591*z^40+5076214026*z^39+9092063794*z^38-38863698070* z^37+40732692257*z^36+27495494908*z^35-72614614806*z^34+39482359310*z^33+ 42689760462*z^32-100110796416*z^31+3649170978*z^30+136877858022*z^29-\ 60571088405*z^28-145213823124*z^27+117755621290*z^26+102246696772*z^25-\ 121497215791*z^24-44876200668*z^23+84208620015*z^22+9980240588*z^21-45026326037 *z^20+3512822542*z^19+18170944298*z^18-5258354388*z^17-4656548198*z^16+ 2789611474*z^15+377840445*z^14-752431432*z^13+141446298*z^12+94333210*z^11-\ 43488068*z^10-2576498*z^9+4861689*z^8-545916*z^7-243282*z^6+55218*z^5+3898*z^4-\ 1824*z^3+59*z^2+16*z-1), -z*(368640*z^206+78759936*z^204-7798177376*z^202+ 150497066680*z^200+926491809488*z^198-127878213541748*z^196+4333116252101212*z^ 194-92983644642547230*z^192+1411891237821847568*z^190-14476449747873267065*z^ 188+57974993679037202755*z^186+1122231804434821168108*z^184-\ 28492099430428788345252*z^182+370835556753680898551237*z^180-\ 3466457754647493514043729*z^178+25467277614674240074182557*z^176-\ 152997215197939598556986147*z^174+769883893496642235472079656*z^172-\ 3309993014616707712248798775*z^170+12286068548487742072524098046*z^168-\ 38854503674497567819898423340*z^166+98822978642721532327277816100*z^164-\ 161145446278034643365817343478*z^162-142292716716014995776751380620*z^160+ 2664603148205212070863265871155*z^158-14221207079451638523783325018195*z^156+ 55067916604094729458688541316117*z^154-173989533668758681932554152791460*z^152+ 454457972217371262785437115001464*z^150-941847278207730443397694992226521*z^148 +1315951676535726625186717873909901*z^146-15627499374892499086783434766014*z^ 144-7281977194735054968661862622763643*z^142+ 29268543643842071959745877631182188*z^140-80055522910495870018513368921191963*z ^138+178053500402904565241624452809945340*z^136-\ 331671356119017816675931864582391421*z^134+489630701173276298949457407465877235 *z^132-464538569953918570392645672304232047*z^130-\ 73111954575479296065575698115176257*z^128+1375678673157593335002982751743814396 *z^126-3129129406300649533308853311842090612*z^124+ 4090521802318793326669617006128703096*z^122-\ 2794521938579896703627218705877651516*z^120-\ 400431877139257073390172997816775377*z^118+ 2057132648223594154514293897804348459*z^116+ 1949208282214342780375050075955961458*z^114-\ 11706744276040580240600634214808599766*z^112+ 21800210470318871372468512723037184929*z^110-\ 25683807947399702019984595398064343876*z^108+ 21382940236847329558017150738411833168*z^106-\ 12625219618435609464224474492594254070*z^104+ 5008174258554575238212385596078878018*z^102-\ 1634009967979219333656821032693890278*z^100+ 1961868469465782537010622230443461642*z^98-\ 3624246462552169661320262194651061187*z^96+ 4539996176798649845695700938005468737*z^94-\ 3770957630177312257064278594496200583*z^92+ 1522006680906067597531720378673231092*z^90+ 1168472990653216827484575434764169041*z^88-\ 3096365122040079373073434370012532718*z^86+ 3669050541021588697672094688801451735*z^84-\ 3148548605883239476985582221722793518*z^82+ 2224381008961352413879498456974998798*z^80-\ 1445930192226446138564317612381426778*z^78+988687686930174677694990723899479879 *z^76-762228433958987493905985694072126202*z^74+ 618096615550352667041516688099291682*z^72-474809914758340724032041981176303383* z^70+327306840608740592644893152674643301*z^68-\ 200281958048192565870604542031881878*z^66+109815087647735609793577708219278154* z^64-54771603279521323947168784370056762*z^62+ 25131801031918228818438516207785957*z^60-10632170257631912956920469041089184*z^ 58+4119751217588378651650173404901121*z^56-1446174664330915685438473436719834*z ^54+455152234130485129170722531607931*z^52-127504014097238456857774048278234*z^ 50+31670314801614166030144261653349*z^48-6964468841076052151291920560645*z^46+ 1354690295434896902195285947371*z^44-232555074120593721776644424627*z^42+ 35036034446802394740370464984*z^40-4581032248571763054306877265*z^38+ 509040001441828544210867475*z^36-45999255179007152850533077*z^34+ 2986187787003911697781056*z^32-60158226018645837707742*z^30-\ 18147939897685309761008*z^28+3475736646566489911459*z^26-395151015727738248919* z^24+33738923148287148608*z^22-2281522925708311107*z^20+123755973124732086*z^18 -5368018490246675*z^16+183816217573920*z^14-4859171011903*z^12+95715087677*z^10 -1325421944*z^8+11548367*z^6-46277*z^4-76*z^2+1)/(628224*z^208-24126720*z^206+ 5772791568*z^204-1019997566464*z^202+72036310273096*z^200-2982658741842664*z^ 198+82645890727987184*z^196-1633355302567880268*z^194+23427163147889339094*z^ 192-232763105542097450138*z^190+1229475105352798691453*z^188+ 5787537137476979667629*z^186-220666390717767574487088*z^184+ 2950281377202644726344372*z^182-27350727342373286714221107*z^180+ 197576217930011633432855397*z^178-1159808414772210919562895201*z^176+ 5643220564094431894769771279*z^174-22992955661092007469888280252*z^172+ 78239618982805866166560174399*z^170-214011709513320393200145896220*z^168+ 395529202546191570854138851376*z^166+74930790097929859308142401662*z^164-\ 4823713154410742640789125247946*z^162+26610547639802501699214550716520*z^160-\ 99272941541573765316896500953947*z^158+293308884467487194944446092523363*z^156-\ 725941992725792269897852489297623*z^154+1531700770701230953980399995413110*z^ 152-2619480426445702741842509277432650*z^150+2575385020956666440077901987225623 *z^148+4499432686690403495320601923345141*z^146-\ 34745081077056040606914781189637450*z^144+121105551713136925328282829822866983* z^142-318066936221517953502258428878290012*z^140+ 701841127814802063228662479499782493*z^138-\ 1347444141266719076559545050826163790*z^136+ 2216810876719448894152498968621570249*z^134-\ 2847750979275136270288226785862119971*z^132+ 1834366466922000360932519537787508153*z^130+ 3429254057650617087578787175065609089*z^128-\ 15494466120988713368893421376058986544*z^126+ 33080927717174510775217853281082076598*z^124-\ 47023712901001741125118508732822852170*z^122+ 42654862914755984553959255801657245314*z^120-\ 12485250186916140101609953912898081887*z^118-\ 31148391366039709828008192258625920077*z^116+ 62296605320562742399955687633954554900*z^114-\ 66464113509700746109349441075277770500*z^112+ 55764118845777226484391752561108715665*z^110-\ 52759270432980368768927960250795764010*z^108+ 63388514129546493372164181497486524518*z^106-\ 73819925880373004637572018001559769310*z^104+ 70729055476730900234366793432472266368*z^102-\ 55422759326895948871535222743427159802*z^100+ 38425792204525402615949097274689190884*z^98-\ 27745190966510447840996071368294727573*z^96+ 24250658103545708573796143054316829733*z^94-\ 24340773477750862776080869834954798051*z^92+ 24342554197365645052552314094292020138*z^90-\ 22654155027324560919450394582691204737*z^88+ 19203524833778237619399199496120112344*z^86-\ 14439385882606881084375341082872500069*z^84+ 9223068331940449503246199380170797588*z^82-\ 4767578165656000132898694536173303552*z^80+ 1948116315614897591684683097566788710*z^78-750331973988610457686979424425455695 *z^76+516255441745874003918772527423187876*z^74-\ 569970237446092330623145821872270554*z^72+568163799314454613889626216489802291* z^70-461228773076139092991049045910233189*z^68+ 314393511785306230125922905225687470*z^66-186613940860788357047700590145469850* z^64+99034722216970869411718009120972998*z^62-\ 47682931456935989016644226476248441*z^60+20893786955948014423103382099606436*z^ 58-8284388338421319713668314321950849*z^56+2943063243792739889950387942270474*z ^54-927795089970952084248323277475301*z^52+257826103840415278692445505871098*z^ 50-63003395189524492106909601816507*z^48+13570008625005415621556838250183*z^46-\ 2595362044476627757245437008109*z^44+446182037050452191079109199615*z^42-\ 70003420053325632588023367766*z^40+10170019003804901336735147471*z^38-\ 1381174156518847754742200917*z^36+175698356667789807902833571*z^34-\ 20826364708844211419088048*z^32+2275592733721786744418588*z^30-\ 225840870982639685350870*z^28+20014735589628148063803*z^26-\ 1556583951761808187351*z^24+104500678360781697484*z^22-5964627217090541641*z^20 +285239012592685968*z^18-11254854430370909*z^16+360041299997972*z^14-\ 9138846694357*z^12+179022506347*z^10-2607448600*z^8+26786039*z^6-178941*z^4+672 *z^2-1), z*(1795681465664*z^344-99441901797984*z^343+3011348386422144*z^342-\ 13726309019045568*z^341-220758184457345568*z^340+4460953192870251944*z^339-\ 12240264080271975472*z^338+48127297056450802640*z^337+2723569810439496229320*z^ 336-18995554243149035493992*z^335-82168816957471718568020*z^334+ 765919839666529024303280*z^333-2729277722546688582535984*z^332-\ 8945398671300629832517568*z^331+194152414550303941538854268*z^330-\ 77182970208439671745480228*z^329-4623994065935498877980192078*z^328-\ 2978865716286256297520009812*z^327+85511937416116172945194964376*z^326+ 244223203778324934842101050044*z^325-1682110387672240802488925549086*z^324-\ 5102890228740272461170300066664*z^323+21078972419333269821060659838732*z^322+ 91884355874495607256551719745697*z^321-75180419316523330821518693444852*z^320-\ 2012870836913729319527697162121186*z^319-1339640232554942829889581180085920*z^ 318+35400763117017053705144990354183413*z^317+ 21695701583393223002954094196344943*z^316-414231908253972466867632149570289179* z^315-251214740404904546953297559857112032*z^314+ 3041128817597508912940551883239937232*z^313+ 4954227960280797857238375226952840079*z^312-\ 10848827116033839049023854670856839841*z^311-\ 98907807699050907893628729471622959623*z^310-\ 31651747043389018064473052908922501669*z^309+ 1423259265661263473538037486120784624161*z^308+ 724376866333637294667360172342804322227*z^307-\ 15247690611916081130036951876525966877319*z^306-\ 5680053005260440243903647173987204048663*z^305+ 134300530862117222535076626646463468546095*z^304+ 22822284607451667085500482714120667742611*z^303-\ 1057526195437914318690687407398952592729774*z^302+ 170670476241420688102127840756568043873760*z^301+ 7566051432881914809078736719308652681967963*z^300-\ 5061307952797565090053596645029390587425579*z^299-\ 46562226541853136022228483423031707418697240*z^298+ 62885854353880047561563196162221339639281652*z^297+ 223099537267564374854979098258535288123004980*z^296-\ 517853203610219211181437060086306689843386839*z^295-\ 662798221248703582722941851638611554525251539*z^294+ 2996184647937646985887079451860045892762854986*z^293-\ 406371518309660200269187052388327098720687251*z^292-\ 11429416662653703686530359934071540959038889286*z^291+ 18133440056114010071203517323088905518522808924*z^290+ 16801382860005980678022541268582985569690689382*z^289-\ 99584752877613947704185632324880271625718399998*z^288+ 119098774870032986141254916910287975900451897903*z^287+ 30533406892386200518026473551690595883177284191*z^286-\ 1018166839759547860152291710974058036425392920101*z^285+ 4185323079446968093017364963045098774234291442030*z^284+ 3041919313244100238909379151386574914489868214162*z^283-\ 44454357585373958947737622833810527082942447805631*z^282+ 9746972942524136347860968683139222312590357565145*z^281+ 306781314358122030151624089144244321141522050447886*z^280-\ 180716112058646685467853571203342194205758181687894*z^279-\ 1692042856894055742070403268354687358114208452056880*z^278+ 1299499457056818390976305650673224795927918102695429*z^277+ 8093153099524646634363206517910485436456317095949821*z^276-\ 6588455569396914494426428063942867693252155137337338*z^275-\ 35223627262862832889214009244976619852254926429872133*z^274+ 26120376857926294610352735165796198676266685607998065*z^273+ 144067070585190775537253250344201296472526936104616186*z^272-\ 82433526165312157087968386834492396318995097248793430*z^271-\ 569505354976555741449693815814451464313989333227530053*z^270+ 189437061131428073963686828391891308762176599514618384*z^269+ 2240964370300224880236425536491971202510639808140905362*z^268-\ 98745113459768571748367973302715380972377803761032973*z^267-\ 8917943420790197677602720401107226038373258771346372892*z^266-\ 2332330201923134433249209995795163641469427663348969716*z^265+ 35321034196596086817836379447244435696605291822541914708*z^264+ 18966972316332344882906205891359372367633953595334675565*z^263-\ 134645931581476116221517588342637503810154986995931446883*z^262-\ 101445399388449403768357730576418254783971231483520054926*z^261+ 484512559991371567990116058384542900749238379719306641138*z^260+ 444306353957610874077267235646914130523473081627582857617*z^259-\ 1655836408088827653676272940467021727873639456511550975546*z^258-\ 1749693000407879927816659942858261513680549932661444567819*z^257+ 5468491046058736518519375586287228070307515696980800924346*z^256+ 6607990948140017997525688318523682871491041073393041090639*z^255-\ 17566343437961519674752198103160343088017092272184689375626*z^254-\ 24642241624559731126849860724105466581537255620313402854017*z^253+ 54439045847210470482165174288422142844868314393656066959632*z^252+ 90370885703254284200697305218671455409787400267740111430580*z^251-\ 161987524387896081782681064632220087598571175333175833630955*z^250-\ 321513553831039739099990552013581912293824621798530725626285*z^249+ 468880105445979469634278745187551596592942599945657354634285*z^248+ 1100171905683933363808974999831791016881136149552917235956682*z^247-\ 1350391345190662639201591180599398701378055298474609891899477*z^246-\ 3598481437224306347413122015562469964768646256305581086442160*z^245+ 3904262750586172726950764170905318167993417642328891839099375*z^244+ 11156338647533468037578176986422351126102864579610548647678524*z^243-\ 11161803959667971159239823526368776121909444294712679744667009*z^242-\ 32469253813891123166378753528867104909333276943856485926623120*z^241+ 30730025178534320804642156912747009064431468467202147221414891*z^240+ 87950139914653791185394204474291667925765438344895157308103456*z^239-\ 79638667194882518694753612522061388732989175540131790082936635*z^238-\ 219901981362338396292598885086391677698739641070047241989691310*z^237+ 191358504320012742424505396797873354223249327970222140686606212*z^236+ 501794337370677237526085984433924652467586944161553306562375210*z^235-\ 422402240257106720969477151980630946678834077334585158170486911*z^234-\ 1024994436521322810904172048842662957484630316347349810832687345*z^233+ 853066667804756049300026529455388365083024403683112765587541338*z^232+ 1805315637716801995477737462425272635284205656618801392215967473*z^231-\ 1583397539474056095812835868547482230864590795793278139495205620*z^230-\ 2496312550225634955512004898724335902588148064758358787871782673*z^229+ 2766740347957646136435954689160551310166403666954865135965905979*z^228+ 1732078881036489507281974723481022110510114874988281757150742913*z^227-\ 4839764946376332373936691753573598716828625607989901951964180312*z^226+ 4129529740576558488652658550496816626055716233100795262265236002*z^225+ 9317474599851136109120673379276714636521132658255366425818969109*z^224-\ 23092052309273765511304532572186374736848732845986195056039264110*z^223-\ 20709848396488081481123909349239305031826443469851882246946075410*z^222+ 70561118612825168582540525679338903205096441657986110142734400850*z^221+ 49912922171778111190570272487072277199892689265397748754305133595*z^220-\ 173316218541658984901434072637143744684353203912427334527184114646*z^219-\ 118288250383243644705871578254829065400793570926167571114765302546*z^218+ 374472543233437066495532942945266448693702464053219996888872991349*z^217+ 259275007042541815639438357743054546067302288515816798847189030352*z^216-\ 740103689698727044960164901765456844884553204230067552185959651906*z^215-\ 511214823865466427230579087165595278366576693860575744652503795171*z^214+ 1368893434352691852171744954706013994722355467908793167091485871149*z^213+ 892625617202968128816318883734651921476440563395750610021967822381*z^212-\ 2405175207027028143896633689197956128392020822032749486062812627456*z^211-\ 1352526013505959811471146087078528829560442539500063687327913795336*z^210+ 4050390433834509992659150732757174168060529110622868607315724874185*z^209+ 1697867137896655390719912487873622350956997773173136141169259410985*z^208-\ 6557220228655305999630180048462338190879659874175957005912054215805*z^207-\ 1518976283976292974732959506097322869855693237871561114316285813670*z^206+ 10178520666798211721057877476454344115691137757436856898218029495293*z^205+ 154753237143751302404136593441792967370087091000377373624515589672*z^204-\ 15041867684175043197681554627952105002079237928971356571521168013062*z^203+ 3251510604233563439642535433589043860612470034943339788082142061913*z^202+ 20947038318132499307346501469384365838196693220937711047606589083987*z^201-\ 9567923382001538655724707474092327056942108601858526314087651723360*z^200-\ 27145439763210983938344387603713948673528702761217478083923825020179*z^199+ 19365413883403634698942175762169230033000649876087163060762982583779*z^198+ 32232030314012912805059216623554107653849449483452945179309392564365*z^197-\ 32560148776827903404940843070655514581247978993421500937073371052176*z^196-\ 34300680206826325934093343809596092431717062918649435523751533646836*z^195+ 48152711294352791417110966474957910855078613921876985241799482703090*z^194+ 31434961926079030729719927723619630159835392734918783938267627742628*z^193-\ 64214660033837898073224011518463423077553131061118090223235268955332*z^192-\ 22448967276796048022745722793254341434750502771295411597663413440184*z^191+ 78189834729280326643665425626799221377589791744303032265752313370695*z^190+ 7625854283097690967888416214275672980458327446565325949740375080397*z^189-\ 87467856075061482452440644058744275753218701732872649377316083483505*z^188+ 10902991989457591504188365704921123373972178231283932331274069902512*z^187+ 90097406728827515732247570757850440039157736693497261704079075865922*z^186-\ 29438461848864817112172577857512794007221073662041552876408085728570*z^185-\ 85421766120469107510426078556742786790051288629426293357933598180718*z^184+ 43669311032799055537131055072845959010644211148887038905917936968001*z^183+ 74384073960519360550343744865607585615762543082194742076651133922305*z^182-\ 49970201492894444459749129348516127537084486173631749231542102655248*z^181-\ 59361065802155792423931231276839036664973421261877079787104912562816*z^180+ 46584531068026899488971509524796573260967572510130296990910964202895*z^179+ 43585525204436115545674239737749062597810505886918094270598829144421*z^178-\ 34315852340740262552591913337827643500274201448215423020728806315489*z^177-\ 30342636449308660794211689875677170660955104261004370558876601763529*z^176+ 16414549315212361303449002209752674680671317262021870144453300857417*z^175+ 22148428853679527355438751525047467017466709696504928807301365405090*z^174+ 2497642206838132188697788199562105869135249600528977953746498686136*z^173-\ 20119568568652825496853923869288891208535030997904736107006181234672*z^172-\ 18123342570503488730372695200511617143428105089767900874497913994219*z^171+ 23716327924382365047530943215260626563326089429828026233030798956831*z^170+ 27947774396562620639886734720953947701403788618214800182402718261437*z^169-\ 30950530291809779037849062306386682063078697165348719180352542937006*z^168-\ 31704518704500998502100001360248507195571324929299980971699662999233*z^167+ 39025471134439216440617971436361004976546972396618492175082816893998*z^166+ 30794947436041906446344433040060864412033041079989513682777710159175*z^165-\ 45228733450286886854109241192018623604635361646660910934872854494885*z^164-\ 27227238381898877377187679290852173497936379048120355714051159234134*z^163+ 47755280606390814368671708980560074736012902261292658881701518894228*z^162+ 22721210708356378533164010628210585948606973138332312380124548954141*z^161-\ 46121522286170912526592191591782897772175371410594864493961619224878*z^160-\ 18306484168017016651995489615418650127547058201923023695978537160626*z^159+ 41032572359295710047926591195317731469262848927824697002799502785227*z^158+ 14378903477976857335125945733600971624032578999670724227113076637511*z^157-\ 33862314612718836088438163679270013554712924234622245357615312607428*z^156-\ 10980475972646390138808152604935635164927297842149745409293750128593*z^155+ 26066320070078630559387753898091809732984097054188658877504892833054*z^154+ 8062471621046711094554956201434465384497483619676697432723324737729*z^153-\ 18780144687052679895973254544280916685756349604793381927229397078125*z^152-\ 5611422021529067802241253472844326888626016657168963501797995387281*z^151+ 12673236871985011998630878895095632079696837617355986455303901810161*z^150+ 3650881545679896689599487451754920851895370318291433378770369735103*z^149-\ 7990465002756136551628881197821449118556723592279066192930884369120*z^148-\ 2193654435260714031243525316450562914775981688647157727298640539439*z^147+ 4677205936010659279821713867217206379311213529561879258533554831784*z^146+ 1205895699520571986137262502411604567478551532852912400629908207241*z^145-\ 2512247265299746950269822916841734865645907688756436846249564910791*z^144-\ 604436516509396149180840386512639096854578221327983022437141649835*z^143+ 1213066636505292447768700427323484092300968791514981195122352128859*z^142+ 279679467606906152024442320200306638772410831886607442195871469995*z^141-\ 505772696269483827209492771818369236493886432807733638578566770012*z^140-\ 125635373487397673449661652529723216131149816578896058828103754666*z^139+ 164069177849854802404171433113743079791922022917472662972404685150*z^138+ 61080464758647154006730927594836336854420714162384636289411742210*z^137-\ 23930616920448257351993361977126006852102318236425868974028517023*z^136-\ 35599967134796528892384722106490400570337643986025590086792921872*z^135-\ 19272678166669776431243175997919688665607183281719161482820803499*z^134+ 24026306879878743390936637757626572097944873298532257593883105828*z^133+ 23759942086380181401348397971095241630017300472641342482417989032*z^132-\ 16675179419133231685630460682869457842456455868496836389109975750*z^131-\ 17165390344983837586462581591732522438355631944861463793206719707*z^130+ 11009626074751749200772697871372966525350179252023135699329474171*z^129+ 10082216781080164766016806232484569784424392673336257463239445517*z^128-\ 6739757739011387977245173304614044887126004289175650599894065498*z^127-\ 5226583123294994795753564183053575256813128633577036490548485542*z^126+ 3821856223337994659219880905918267956196929504066186369389766517*z^125+ 2475636533727449665362755602268201295805601681414349789257606187*z^124-\ 2022412437781096379737876514846018036069761294884902969503988779*z^123-\ 1090932876277179901736902888416054298418897509172735759271745010*z^122+ 1008401855536680541944617284583259212171885016004900446150193590*z^121+ 451758318906908170061819503084920334905464877019701261641349599*z^120-\ 478640599647527288903281468304683500354825898727919230729709015*z^119-\ 176468811110616299546392413668979347729718459919503544213257802*z^118+ 218389342074766002026640168338545186627033943630936066511053015*z^117+ 64699329472621671586538986954917888178632374760758150135724777*z^116-\ 96497623728246806423732244667830878784433264002694314830990370*z^115-\ 21804321760342987737268036494543051881508080998606703309877171*z^114+ 41414714521699512317481894061830063935036782301963515783253374*z^113+ 6401112436656598749580717417915678491056242526849574381037697*z^112-\ 17229570348038843366632077895330122600386230835343881704218113*z^111-\ 1390985911722537481775940983524674162826363535701770990496204*z^110+ 6911768606768070638149260226255635804277679494617762815842755*z^109+ 29320432211392968221488704461688767685468040976787109663183*z^108-\ 2657737146104985573945900630992012231386910240793068406238984*z^107+ 200115620129248548618074687998085099031554455676027635124548*z^106+ 974680214031284332883255236849975826214527879466138708430310*z^105-\ 155270809733216633662344551840027841067275241677781684635324*z^104-\ 339569122490562579085174500918476875995124883105767995107437*z^103+ 85126943204742294496415315061476084664938846727227831925676*z^102+ 111962519671802544288010890500319651197978542926396634079346*z^101-\ 39682168559765950340729459656421992216103538292535304880235*z^100-\ 34754339272332264198883456119358897967090665068429471273901*z^99+ 16649232213427218982394874384847810011516411459245513828436*z^98+ 10059671354635556063720109077218648523275095225728103302310*z^97-\ 6445670095401253696643798560631630859460123067951677256835*z^96-\ 2663276907071349196683150606115543650116741106639905053628*z^95+ 2330055153759487605922609636845562938411808849671736325740*z^94+ 618056049838206729295142201653938195128786768297216825830*z^93-\ 790091370913464972285984248964432268592960814089924208999*z^92-\ 111777171974351711444056035141694394652797717971753793106*z^91+ 251262065355726221216460607204923171846911704861377869592*z^90+ 7770308305682158203667850581256723672384466496840957223*z^89-\ 74691855971575385126612984880192498863976268156572757534*z^88+ 5525318209413886533969949830384484337475072057332652994*z^87+ 20639321353147001107416462826301698498668152174599872514*z^86-\ 3719283580189567871940651259561515538116778136367455394*z^85-\ 5258994147487633095562688973145663244249563566852225119*z^84+ 1559426513601278226654090571883226162964728484256738460*z^83+ 1220408573714132308309598795114870173848160721782600543*z^82-\ 533632394648590534260057722327420970907830056933761746*z^81-\ 252353054637608356251600299647576166231309446146550655*z^80+ 159473805626948722855329657211659577433131897258058044*z^79+ 44424629182206355858525496224202632875741803073559403*z^78-\ 42675326925634508693804992138388702773273618658907556*z^77-\ 5862311489263324042290876940617560202114736342706420*z^76+ 10324786860696612525267609344158086419334648761384039*z^75+ 242112638652750192107467337427077899782602151137525*z^74-\ 2263641749659538510329592459336571652227388192918098*z^73+ 173814050631175607974659321317321634595083294366546*z^72+ 448871102307484406952672410872623599259767030896916*z^71-\ 77486048823796385099585495587829078316339802481007*z^70-\ 80084484353854951148287004996108691871261668495214*z^69+ 21855217587204567050030855802466802348246570009686*z^68+ 12736448524287244390410354539720634865881759352452*z^67-\ 4961513971234982155041588347815028371034346159316*z^66-\ 1775763247911568153848778338430178802985514698969*z^65+ 966868002655973957070277406031463339296840412905*z^64+ 209813268503243958062052887858784572643855750961*z^63-\ 165996668097015483226832280771814840736224558719*z^62-\ 19245984240925066706428048993420665785015248075*z^61+ 25415449510959048355770601061970100486376533418*z^60+ 918212458310437627050153055842067269579532823*z^59-\ 3489171581017184127270505826722707122398284062*z^58+ 112081711601055432591780166733604097243483884*z^57+ 429964267861937253226292932039601436219744206*z^56-\ 40846919699873208101272307248070940927836452*z^55-\ 47426756353764971250396422180140463494923296*z^54+ 7475633305275742669592164309897762913265635*z^53+ 4648850077680324702097945906263690689807843*z^52-\ 1049857097011038622051870774091628386574531*z^51-\ 399303837357724195196294784284205800305405*z^50+ 123326878087188991740909231780505446559990*z^49+ 29251009773349270105204522933882369734085*z^48-\ 12470788801346343815105565474451598878434*z^47-\ 1721202417055975652516954797626034635504*z^46+ 1094801304453051980664707079084407395284*z^45+ 67360553441479865926950261781236285122*z^44-\ 83233818584308552474691274176427603447*z^43+ 243675809138515967696510793130265719*z^42+5416360119669035706696096790629995887 *z^41-336957946058358644917812649290188854*z^40-\ 294724882598096232888017348604129480*z^39+36216168634231399573898386206409574*z ^38+12822290114108390156300859273867864*z^37-2509396424800561096145586977600034 *z^36-402192952583155031207139836363523*z^35+125799528718665600361026756825174* z^34+5972764027077383448934163402502*z^33-4365663844189523942939513729592*z^32+ 190026140461301169592138008063*z^31+73491360084223835480395256311*z^30-\ 14451181532003776400217179363*z^29+2245106691389399109145477360*z^28+ 242680505881142208327855316*z^27-228249524741364740161878683*z^26+ 17317078336943813810162865*z^25+9390800459810503517197209*z^24-\ 1511499398418159897072000*z^23-230848874934063944259576*z^22+ 64103530310517233051040*z^21+2725564878042221200990*z^20-1813486279780107017640 *z^19+34032458937367287378*z^18+36166409720089747217*z^17-2371799323943320261*z ^16-499253640837408613*z^15+56976673659364693*z^14+4296425810787033*z^13-\ 832166479694979*z^12-13317982249569*z^11+7810941145184*z^10-157012453354*z^9-\ 44514687074*z^8+2129745626*z^7+123720234*z^6-9899791*z^5-9773*z^4+11764*z^3-368 *z^2+29*z-1)/(1170281084672*z^346-172117440702656*z^345-13534377756087424*z^344 +228483671406519712*z^343-387037601202101152*z^342-35513139436466105040*z^341+ 239692050841268696832*z^340-105890471299464179416*z^339-16780043545410406217264 *z^338+146374941422542186984456*z^337+322274963285963939866396*z^336-\ 6412363553363454569910800*z^335+12732135626882790510074228*z^334+ 89571569429947461064973460*z^333-664864232252535133504769156*z^332+ 313678583321637497557805700*z^331+10630781309536451543954671096*z^330-\ 360198508673820964182607302*z^329-137737056832756859034672311216*z^328-\ 751177162158904871935491702982*z^327+3679830722045342850145653805158*z^326+ 15709974141954456059158014595262*z^325-57184460543318428409178209393232*z^324-\ 241216465251225473540977687868716*z^323+239989115750579691617979513995958*z^322 +5302996465562761729212478430802892*z^321+3342956403845393557763875856263244*z^ 320-98592023106412824395834310223263750*z^319-\ 56353949361490708767776636015991732*z^318+1200140620560930849055395436681975610 *z^317+686703781538958936634079445601058762*z^316-\ 8953370052898889481504477508359284018*z^315-\ 15202935591305866129598425253047909862*z^314+ 27945097157138618349963773104298154029*z^313+ 326257103395687204968089968608514857106*z^312+ 214760513178585541911318594981333775282*z^311-\ 4982555621032605664568460857637444563842*z^310-\ 3839595443738481519815255392058090340306*z^309+ 57599980397598641248108737239664596939365*z^308+ 26291200492810340277156317141702494271877*z^307-\ 544104314359152228712399836218565607727982*z^306+ 20109028171526591337654558728365496498093*z^305+ 4288163117475665127916538904769799476583672*z^304-\ 2888067685192743408283524355549515737840038*z^303-\ 27234723562113234824037246104800753874055453*z^302+ 40405586719419277343860930121491972530239875*z^301+ 125788901167441482215979598349816158515670884*z^300-\ 347027792123141399394675952996738006936273510*z^299-\ 270282789747454039672066548691210190662846264*z^298+ 2012851600135020310400559482671631502553239563*z^297-\ 1680338277992257639055428778659554769777753586*z^296-\ 6687404699181084663023221627440946129193449191*z^295+ 22870574756444369630077710471200361257998061797*z^294-\ 6671310423897651116633375037784790644088073294*z^293-\ 136482565264868162411696849282368576950700865277*z^292+ 253623906248085302410986129545395023129746785708*z^291+ 390254292219237278955057695507065025730174152239*z^290-\ 1769849786399098109875743072700689918468108613598*z^289+ 1277111692921912196949386377632460425702020467122*z^288+ 6137879418609785012366728591180380458820633081635*z^287-\ 25087409397406084294226377236345009203705804520937*z^286+ 5990066186197970884674400991808195761234411886940*z^285+ 192091599023812246468712747185728269311371532081692*z^284-\ 253228825136358212599062077277425313424615258129078*z^283-\ 1036794028588191182408128424587463622688350266207721*z^282+ 2131463580703913765890941111437408706405691245708224*z^281+ 4362894602323560346978482714888579876918603194538379*z^280-\ 12340623624251244526574714651289968064609268432802204*z^279-\ 14697591503711596050775940390794191337732469876488741*z^278+ 56979589146114178459294530339141482948066372135906740*z^277+ 39354146520106457694433062813388434237108902713867226*z^276-\ 222127205161684123400037800573818228154490219784376297*z^275-\ 82472886254845969696934522173921752699001446266298814*z^274+ 757928989586569052086295946457911355131551259708426312*z^273+ 176000075592077701074124646581831634259455469512307671*z^272-\ 2323799139578728478020080064454268929029341772368775171*z^271-\ 982518517671495569199080977679298436452880198386287102*z^270+ 6492842461658459679793801959816055362040267382491997148*z^269+ 8271831293462411495153599900238354144795674805704137837*z^268-\ 16929786762032263203700964693745904723616454636077046072*z^267-\ 55432124409332428347564972990985569387961394670310394497*z^266+ 47114922152503748857284567170368109487602822909053369573*z^265+ 291881254684424659035870396549237665447368925442330938968*z^264-\ 182134598657716635499263262685112354425424692303857061386*z^263-\ 1282630591410462111338352315109834928698067413550534610016*z^262+ 931968261910766048261491727320696485091303619572457013184*z^261+ 4954605164965808175511139031126238082020176845084057010896*z^260-\ 4725984975491434309193964661018607974888035597829642492506*z^259-\ 17398115177031110938655105154959063902924352180573073516525*z^258+ 21000300240525117017093147337116312354555549645677543384315*z^257+ 56042449914876756505107275615596060830181664378169196208416*z^256-\ 81152571679619937150708106795702871821844837840953041109455*z^255-\ 163853993050263163447643875352719223745610925954054191281675*z^254+ 277693986509548858359622092480865699821439536719553649919094*z^253+ 428902545947216305967498514135531087379715933142222515056040*z^252-\ 853259423150220221799148637919974419533546789279278309205068*z^251-\ 1007551420816261023151921504772338928799176671496011995313632*z^250+ 2365242988171993169708741269589388540585147259160782748690678*z^249+ 2205874577240505239212500157524096592840415663301978802198166*z^248-\ 5914120136455136240177351107939965296462105650766736161456878*z^247-\ 4892948195192642205543570843613699773032657970009552508508826*z^246+ 13374926272612848136090372671612909669484160423474889545433254*z^245+ 11983332253455490409533409564730090600258573298779384736445675*z^244-\ 27787236813875934817103043456834588641152212100282756179967558*z^243-\ 32293999305893090869418658051287816825946471210811502607532460*z^242+ 55713936536146275788372914359690769290829396691794426560718539*z^241+ 87860213875000236670762886799394452712218881839597727426558979*z^240-\ 121185458402327490177326442896678123053397739430329253126654633*z^239-\ 221624691453806460058364580348626450492409277856019524885147816*z^238+ 330385276714254729835897223442683347906352064594296098018481005*z^237+ 487008803421171532027030262660534159678091727263744979702894974*z^236-\ 1114691453163381939454158087930944216375747641308373068458398264*z^235-\ 866324997308899270581985480877838721473314048266589410709789300*z^234+ 3987363880082167230613780347977012661253015573602037679246389090*z^233+ 1021598507806994442787000082737573548936894051398942218616076402*z^232-\ 13533184842625089933395787982607372609978771497589818997560455009*z^231+ 203078967201799490541511138252890532159612915845570430632616100*z^230+ 41899365173123746048181519504564446464775250689105257765976221237*z^229-\ 5367801792696540754332469420390055548670018138873785470219527130*z^228-\ 117563297792618238990656363577324848283946377801403424447988871642*z^227+ 18272639144065124422658179771595565229739292577233556949860806689*z^226+ 299999462388814254434652987298059698266804355247934596705234349834*z^225-\ 41172354739499580197884204582192005664492411255298612923057188346*z^224-\ 699901544315761192679818856459596526847847584176189938331535917009*z^223+ 67194657158492383340265792796912122753015222198441207211269532761*z^222+ 1499740314503175096097836348647951000049019845636211317709957565770*z^221-\ 68633638278228572997920359420347420189440701159280067498607148350*z^220-\ 2962433253778884489566478815940057224940611163205636490016273058248*z^219-\ 9621604806876469406583743002797531997539909000868213177146717770*z^218+ 5411794956880533917303654880818147261328061572971440125541130909763*z^217+ 227703469951173119108394223642506238960330044485290078187802466783*z^216-\ 9176663030955743338292779691186554014338784683151709183601194279942*z^215-\ 559691409347382743631127144582413404441220916627905165637931682584*z^214+ 14518058533026692872999489080994743071003247883136205522080999027000*z^213+ 690314362804942997839596280873319451054751363059703744980378979478*z^212-\ 21594491428608247937456572343431745514197775589182217036985077001732*z^211+ 309992323907081751870144559408173989828706322647948072775432571070*z^210+ 30526160793998211723829027739524962631867971558977675385798850198527*z^209-\ 4348930104607227539020802449381371540994052188074250670195234577484*z^208-\ 41548784037974306739599726138466956643335664131431312159973266045550*z^207+ 14513709487586891187610594149104875323264246651702587767568996443772*z^206+ 55100877093525207535936443757070330511876352987029336536529743136630*z^205-\ 34855737606578577652343326310439239221048422747340779861071814154157*z^204-\ 71553940133632051265625619190200739706001434557716512657065569329547*z^203+ 69590446165367699127097675136486844966534816935904635598911511435656*z^202+ 90345720962166911379076551978535613147524292892371614226892447412554*z^201-\ 121764275997389804739337245581862162697816804172211680515825444886532*z^200-\ 108659176321582570673012807394020504486887564536643823825462028014752*z^199+ 191752613157445442775971497326454645333540780805711382244776211533828*z^198+ 120417285473462823336955682978415817650842231069560210031192981842667*z^197-\ 276229684660783126578711149786842229175797115504323526002281498669617*z^196-\ 116785875885011337264660787934929197775367648919671246639043265563128*z^195+ 368193881812160838829855065559619580723291250793380437203269373650898*z^194+ 88999330233132738305152547537035201023846178104993987796946511811734*z^193-\ 458105667799156645481125068115791491734560518511202322644310985814189*z^192-\ 32988783100800563007258648699065070090624484833441157107080934198536*z^191+ 535686778706383338307373817421263914748633685378299221519015520261716*z^190-\ 46258928144085483231514276472080180450311884122720340696003058079738*z^189-\ 591972689316024391857909696180513673107203164408753292794930181754421*z^188+ 133151954407491747477088229175465670636558809123396827283881330826298*z^187+ 621395912814995209771910794727644754579525706117357871541490984914306*z^186-\ 204103243788297902390474928496985015008604187926867299055261317214355*z^185-\ 623329965795438175546952357474948283356059975215927390177178330249124*z^184+ 233784789606904758468782869136966287336327041160401542096642545498273*z^183+ 602212736370660546559404004124642630252988740977673112436605428979157*z^182-\ 203315582864397842380021577505340431230299464573308194949442119088188*z^181-\ 566146378742831546269435331973117430946984575000058897843278854914960*z^180+ 108027400520673834793233706726625148933328308387610913349895030736389*z^179+ 525084433860043361401251508523341178838772818893141848239513367557769*z^178+ 38374701842284633072319267981288638167255855794013326789077355660125*z^177-\ 489525449577473531014120785979782835838693216991333078604670944249964*z^176-\ 206436479178460454145905487421827990322678118591055803735010580254446*z^175+ 469042193717276296430438113630955794773022401135801121862485357412369*z^174+ 360795030911776527575427409223216074385435481143958264401521401805363*z^173-\ 469422191925356733608785988672838503949802554459891890531641360751808*z^172-\ 472985084949837844793568113407406070986104344870345610838160017374703*z^171+ 489092531154954924868429249932283349317009653263539326149496876784899*z^170+ 530358587882380962909805631886528159216698642349475614920831431020315*z^169-\ 517715414946920816754732817283538403465504042379552823277352772950022*z^168-\ 536689181467851938552521598874307130995473158455626219115535804740088*z^167+ 539253049416305852605291112266965247379696771353475624759569743150912*z^166+ 505701960901437878310341568196806758793414159301130108175700418931998*z^165-\ 538528829961218121011184422375472660047525390575577833290935658350602*z^164-\ 452812961872040780572795562631638572798033250799438512490792936505988*z^163+ 507572357455508458413501713875811400093419394240674773690684443553925*z^162+ 389850310428384780139301033289108105212698790476332316488612289719467*z^161-\ 448254381552322590923001430602011459981057845689008787040755842357535*z^160-\ 324019774598100218667124022715731987766530452275929954835259108612166*z^159+ 370319492485034461272606024855071478295050689094180642053469062445692*z^158+ 259442001394730778980434174028916945182036617080734353094554718940123*z^157-\ 286630016795842250996482083480737821131934472787997230543479329503114*z^156-\ 198999221275345647626177211963655620818514384467926348339626465212251*z^155+ 208471186395463771043447966842428117659366018389710567885753267016631*z^154+ 145236958624897711867898588143115300246465947559411961783225824205849*z^153-\ 142911180408668370666417759997341772947820062054614653299599265717085*z^152-\ 100256954975732104127541726515627808830671180516782255697045200841559*z^151+ 92526659308097252479139039632876185675612460079191399360710362222705*z^150+ 65187618604964041245132134225120957935865371860041663086011827926066*z^149-\ 56594746458196421100906236706133460704826115072706121713485310822280*z^148-\ 39857697306614283023410212924909922124642157284947982214202972778467*z^147+ 32642431166313496181922998049483777712690305751250016450350627827035*z^146+ 22949392807947942411986546044614449752444639272315205036053149366349*z^145-\ 17679129276556445963579825780382348157449173067485889595249375073434*z^144-\ 12510112102524749248840128005091176600771151736556906748929944698008*z^143+ 8931985571630084284948812296834297935913907037328959845014449644387*z^142+ 6523218647114315687894961609407187238839578148669407550181910293473*z^141-\ 4171359808833205757866325468599948505024724465600233303704216978699*z^140-\ 3304557997443167535366414407528273993063559575433238995374246475653*z^139+ 1778474159265510023739023812914457660702313219598380663782608348473*z^138+ 1656171303470637132877158650656165512883523951407253994722801445011*z^137-\ 679447463191303411646441064925652388880096356718584081717486877825*z^136-\ 833270882725138031463851748815425782508443203836309700244077688953*z^135+ 224654604541285293900850300994642791821939825574801817130138931255*z^134+ 422890518667403396090369523788399095880980724388778675493338552453*z^133-\ 58823143370302015740261251358444227697468071125827580487003937038*z^132-\ 215263778112996642484261301694494488779391837160693750744999107891*z^131+ 8058568380179492405505505286213910783426727021869944319336420066*z^130+ 108724973707528136117779226000414508781525994550396904993824199017*z^129+ 3102324194118633685011641833202309871363486476592724649292972791*z^128-\ 53922624513106140570421092827318793042760116893843733788215608687*z^127-\ 3316119664032501486413001044571423844529376322088248990082666267*z^126+ 26053306420009248987356932795133201929294911755553946728714902874*z^125+ 1777999896728172238434502697950565760524462925633969943816390038*z^124-\ 12198040489110440021642802065586167459469801305276977338946249756*z^123-\ 684760334741600269296405498648239091637852938953349074492401300*z^122+ 5517925795958100105937818533446984215490021304423495500396611020*z^121+ 173200958553141618422850616810391756829694921760911784056436758*z^120-\ 2409869144909552934123953700995007861234665214632849986306524836*z^119+ 4339481331591290107845239091222712895950626799469877775001479*z^118+ 1016693736586728311565850556893852828880092095411031213290349553*z^117-\ 42082419981743391855576614326927748194376688824060830910117833*z^116-\ 414493261789353006618360328629456069526705151479185189535868619*z^115+ 36039763936754566124306316170933667110490843736523179739584329*z^114+ 163099005389937188355891232215383378563946495502970589308344321*z^113-\ 22643255647921983655148687803107660096365210901302226388511614*z^112-\ 61753070584856000549013915298031402218009556010315617849546507*z^111+ 12207474574740755143717317311139314865424403133598615685419795*z^110+ 22401513976346646930360163217691504075018220655851446347183842*z^109-\ 5923978866817862206157541570405804152746103675329235699768756*z^108-\ 7750049775992828797987067590481931082658819055372219791690040*z^107+ 2640789464452630722756793840174322788330102769833811430653758*z^106+ 2545962193816543690704433094804775079550098980556527815897336*z^105-\ 1093399456588460034558983529146522578171026294527267757335974*z^104-\ 791043294470540592546341050914188458088649396611928975570767*z^103+ 423730362715460847783069824067886885505991594287690997017254*z^102+ 231506523249149080972363128880853700212595854100169681636129*z^101-\ 154730209357171503470856219808793227523123939585596913854385*z^100-\ 63426671999428511667035882939683243891634482337162146904638*z^99+ 53583894382081652883677797824205253907793879822627825868145*z^98+ 16058193198823800422815280595604510271664902382698263008795*z^97-\ 17700490482848154810900635385216801192520281932725602579943*z^96-\ 3639299738005315505795477459668876620771169642737004641488*z^95+ 5599714921387146154016951109416409615636602561244513910881*z^94+ 674323716995646541322269377400278726942442564304600094139*z^93-\ 1698268249821071938915343721871896387719868617349770820742*z^92-\ 66158186812916992925967741851312976608965936242803965242*z^91+ 492499715805180394912394925784669147872168316560882701046*z^90-\ 20916473698386227827043005418563192280253199983748107586*z^89-\ 135802495246314796086585000442602765876793931505970515934*z^88+ 17240700890131682006314708726728140188656397046755003162*z^87+ 35318761221202815206255015575437657522527439221062501132*z^86-\ 7710560031456496612462148624494954625948523957395476721*z^85-\ 8573152109785104379351724228963985048699478409710101536*z^84+ 2768260211499237016772389251863463072749945628474844927*z^83+ 1914055844868271099821254254530556717538600614846182467*z^82-\ 866919761334529534444678717823228609530160716809667762*z^81-\ 383846573052424782917948346756561858358583492965261444*z^80+ 243855554946303086357627047165981066273330651409508038*z^79+ 66012527824415711821405047760006101927114064825148422*z^78-\ 62303349723393532887378200766803433846738813075470290*z^77-\ 8609753773375482203663341659273677666752784791994458*z^76+ 14499824618788285253798164104294495974304856205666263*z^75+ 397586519600295225282187323449173715667244839326047*z^74-\ 3069548860672758233914636317038956871890514713173026*z^73+ 221230227378288858490289000731874230978766487327486*z^72+ 588845316203963505131420248963564669566971075276858*z^71-\ 99052745985163938730322020796588965312143037333201*z^70-\ 101793921087304901129087461613034543939647946787775*z^69+ 27401337385246192007058394284923167468367825900885*z^68+ 15729390099826093985120629038019416347621393679178*z^67-\ 6077347277405395508818514361862279221720124206838*z^66-\ 2143319629416915818700884392914486504901698155959*z^65+ 1158090753207565404900541211766089207710759151475*z^64+ 250667608168262330548327851790396833772162092575*z^63-\ 195217003482669322474109402866224071112903701651*z^62-\ 23518651381854036036783373783764843932048878449*z^61+ 29550613150554709733706871080518509211455241524*z^60+ 1363025303691739662778867929446609370522713410*z^59-\ 4050052477588489559546135199900554896715365168*z^58+ 64850698711793782144459909831968195136805915*z^57+ 504600043862163111393479019636040580115204580*z^56-\ 36110043056009808695933693906412675174832289*z^55-\ 57202139599283718380199020097082487746798476*z^54+ 7127358770569908335839728247984785987592962*z^53+ 5888557780851906807056866357083692003747523*z^52-\ 1053683175076010773790827085358819351485828*z^51-\ 547522307050770932723453353413230617813663*z^50+ 131044136949393586673434888053647545393853*z^49+ 45479223207631241500792258469634679340680*z^48-\ 14262612803172184926089096638369150275388*z^47-\ 3300253878760974201668941056186482592808*z^46+ 1379732912140952036672935400398271173006*z^45+ 199055855603907561325178371798536508242*z^44-\ 119063151569071636885336839033864023980*z^43-\ 8633865581426894184628947626361498101*z^42+ 9122053521034285337206107171856979292*z^41+79820236025715394243235865197466411* z^40-613033505391030622219723832167804428*z^39+ 32125716054811006762365753922441731*z^38+35409793601369237369014354175986453*z^ 37-4143992240359430717522951059582042*z^36-1700097092352448954589920296895642*z ^35+333691470171575612471947832636218*z^34+63540946352235326477001268210916*z^ 33-20432332328636553917443975650928*z^32-1520931362367912755974411616543*z^31+ 994810156415450654496083214006*z^30-4160110988127270244939197897*z^29-\ 38709105140194309612654427885*z^28+2677983456826827920599670579*z^27+ 1181256147844122008143519512*z^26-161119756369973459846902693*z^25-\ 26734009946498383363932001*z^24+6197279772998412009144823*z^23+ 372896297511792587840014*z^22-175179919685589799300012*z^21+ 376602873384538777862*z^20+3739882318812972938446*z^19-183867214503952414895*z^ 18-59497457925059236687*z^17+5593194099436891632*z^16+667143606560699487*z^15-\ 101932255346325144*z^14-4420071444358522*z^13+1268377600301861*z^12+ 1130898099500*z^11-10868239247629*z^10+310781670990*z^9+61241836952*z^8-\ 3297704022*z^7-200235080*z^6+17049834*z^5+237578*z^4-44681*z^3+429*z^2+45*z-1)]: normal(z*L[n-2]): end: ####################################################### end pre-computed data ############### ## (written by Pablo Blanco) ## DisjtCycles(M): given an m by n binary matrix (as a list of lists), constructs the corresponding # edge-set of disjoint cycles in the (m+1) by (n+1) grid graph. DisjtCycles:=proc(M) local n,m,i,j,T,S,s,e,t,E: description "given an n by m binary matrix (as a list of lists), constructs the corresponding edge-set of disjoint cycles in the (m+1) by (n+1) grid graph.": if type(M,list) then: m:=nops(M): n:=nops(M[1]): else: print("Input is not a list of lists. Edit procedure accordingly (replace nops and change indexing)."): return(FAIL): fi: T:=table(sparse=0,[]): for i from 1 to n do: for j from 1 to m do: S:=[ {[i,j], [i+1,j]}, {[i,j], [i,j+1]} ,{[i+1,j+1], [i,j+1]},{[i+1,j+1], [i+1,j]}]: if M[j][i] = 1 then: # include edge if it has not been seen again. otherwise, remove it. for s in S do: if T[s] = 0 then: T[s]++: else: unassign('T[s]'): fi: od: fi: od: od: #print(n): E:=[seq(op(t), t in indices(T))]: #print(E); {seq( {[e[1][1], (m+1)-e[1][2]+1], [e[2][1], (m+1)-e[2][2]+1] } ,e in E)}: end: ########## ## (written by Pablo Blanco) ## AntiFindMatrix(M): Input a binary m by n matrix that represents a hamiltonian cycle in the (m+1) by (n+1) grid graph. ## Outputs the vertices (in path order) of the corresponding hamiltonian path, starting with [1,1] and ending in [1,2]. AntiFindMatrix:=proc(M) local m,n,recent,Ordering,E,numE,V,Nhbrs,prev: if type(M,list) then: m:=nops(M): n:=nops(M[1]): else: print("Input is not a list of lists. Edit procedure accordingly (replace nops and change indexing)."): return(FAIL): fi: E:=DisjtCycles(M): numE:=nops(E): if numE <> (n+1)*(m+1) then: print(numE,E); print(`input matrix does not result in a hamiltonian cycle.`): return(FAIL): fi: if M[1][1] <> 1 then: print(`M[1][1] should be 1`): return(FAIL): fi: V:=GG(n+1, m+1)[1]: Nhbrs:=GtoN([V,E])[2]: # table of neighbors. Ordering:=DEQueue([[1,1],[2,1]]): Nhbrs[[1,1]]:={[1,2]}: Nhbrs[[1,2]]:={[1,1]}: #print(Nhbrs[[2,1]]): Nhbrs[[2,1]]:= Nhbrs[[2,1]] minus {[1,1]}: recent:=[2,1]: # the vertex that was visited most recently while recent <> [1,2] do: #print(recent): prev:=recent: recent:=Nhbrs[recent][1]: # recent should only have one neighbor left to visit. Ordering:-push_back(recent): Nhbrs[recent]:= Nhbrs[recent] minus {prev}: # delete the previously visited neighbor od: convert(Ordering,list): end: #OneGraph(M): Given a 0-1 matrix M, outputs the graph formed by the 1's. The #output is the set of vertices followed by the set of edges [V,E]. Try: #OneGraph([[1,0,1],[1,0,0],[0,1,1]]); OneGraph:=proc(M) local V,E,i,j,a,b,v: a:=nops(M): b:=nops(M[1]): V:={}: E:={}: for i from 1 to a do for j from 1 to b do if M[i][j]=1 then V:=V union {[i,j]}: fi: od: od: E:={}: for v in V do if member(v+[0,1],V) then E:=E union {{v, v+[0,1]}}: fi: if member(v+[1,0],V) then E:=E union {{v, v+[1,0]}}: fi: od: [V,E]: end: #IsForest(M): Given a 0-1 matrix M decides whether the set of 1's forms a forest. Try: #IsForest([[1,0,1],[1,0,1],[1,1,1]]); IsForest:=proc(M) local G,k: G:=OneGraph(M): k:=nops(CC(G)): if nops(G[1])-nops(G[2])=k then true: else false: fi: end: #IsTree(M): Given a 0-1 matrix M decides whether the set of 1's forms a tree. Try: #IsTree([[1,0,1],[1,0,1],[1,1,1]]); IsTree:=proc(M) local G: G:=OneGraph(M): if nops(G[2])=nops(G[1])-1 and nops(CC(G))=1 then true: else false: fi: end: with(plots): with(plots): #GG(m,n): The grid-raph of an m by n square in matrix notation. Outputs [V,E]. #Try: #GG(3,4); GG:=proc(m,n) local i,j,V,E: V:={seq(seq([i,j],j=1..n),i=1..m)}: E:={seq(seq({[i,j],[i,j+1]},j=1..n-1),i=1..m),seq(seq({[i,j],[i+1,j]},j=1..n),i=1..m-1)}: [V,E]: end: #GtoN(G): inputs a graph G=[V,E] and outputs [G,TableOfNeigbors]. Try: #GtoN([{1,2,3},{{1,2},{1,3}}]); GtoN:=proc(G) local V,E,T,e,v: option remember: V:=G[1]: E:=G[2]: for v in V do T[v]:={}: od: for e in E do T[e[1]]:=T[e[1]] union {e[2]}: T[e[2]]:=T[e[2]] union {e[1]}: od: [V,op(T)]: end: #PlotC(PA): plots the Hamiltonian cycle PA in the m by n grid. Try: #gu:=HP(GG(4,4),[1,1],[1,2]):PlotC(gu[1]): PlotC:=proc(PA) local i,j,C1,C2,p,m,n,eps: #eps:=[0.1,0.1]: eps:=[0,0]: m:=max(seq(PA[i][1],i=1..nops(PA))): n:=max(seq(PA[i][2],i=1..nops(PA))): #p:=plot([[1,1],[1,n],[m,n],[m,1],[1,1]],thickness=1,axes=none,scaling=constrained): p:=plot([[1,1],[m,1],[m,n],[1,n],[1,1]],thickness=1,scaling=constrained): for i from 1 to n do p:=p,plot([[1,i],[m,i]],thickness=1): od: for j from 1 to m do p:=p,plot([[j,1],[j,n]],thickness=1): od: C1:=PA[1]: C2:=PA[2]: p:=p,plot([C1+eps,C2+eps],thickness=5): for i from 2 to nops(PA)-1 do C1:=PA[i]: C2:=PA[i+1]: p:=p,plot([C1+eps,C2+eps],thickness=5): od: p:=p,plot([PA[-1]+eps,PA[1]+eps],thickness=5): display(p): end: #GtoN(G): inputs a graph G=[V,E] and outputs [G,TableOfNeigbors]. Try: #GtoN([{1,2,3},{{1,2},{1,3}}]); GtoN:=proc(G) local V,E,T,e,v: option remember: V:=G[1]: E:=G[2]: for v in V do T[v]:={}: od: for e in E do T[e[1]]:=T[e[1]] union {e[2]}: T[e[2]]:=T[e[2]] union {e[1]}: od: [V,op(T)]: end: #Paths1(G,a,b,k,F): all the paths of length k from a to be in the graph G=[V,E], not using the vertices in F. Try: #Paths(GG(3,3),[1,1],[1,2],8,{}); Paths1:=proc(G,a,b,k,F) local V,gu,G1,N,a1,gu1,gu11: option remember: V:=G[1]: G1:=GtoN(G): if not (member(a,V) and member(b,V)) then RETURN(FAIL): fi: if F minus V<>{} then RETURN(FAIL): fi: if k=0 then if a=b and not member(a,F) then RETURN({[a]}): else RETURN({}): fi: fi: gu:={}: N:=G1[2][a] minus F minus {a}: for a1 in N do gu1:=Paths1(G,a1,b,k-1,F union {a}): gu:=gu union {seq([a,op(gu11)],gu11 in gu1)}: od: gu: end: #HP(G,a,b): all the Hamiltonian paths from a to b in the graph G. Try: #HP(GG(5,5),[2,4],[3,3]); HP:=proc(G,a,b) Paths1(G,a,b,nops(G[1])-1,{}); end: #Extr1(L,S): Given a list L and a set,S, of members of L outputs the sublist of L consisting of S. Try: #Extr1([1,4,3,5,2,6],{2,4}); Extr1:=proc(L,S) local L1,i: L1:=[]: for i from 1 to nops(L) do if member(L[i],S) then L1:=[op(L1),L[i]]: fi: od: L1: end: #PickSE(m,n,K): picks two vertices (S,E) in GG(m,n) such the set of Hamiltonian paths from S to E is non-empty. It tries K times. If it fails it returns FAIL. Try: #PickSE(5,5,20); PickSE:=proc(m,n,K) local i,G,V,v1,v2: G:=GG(m,n): V:=G[1]: for i from 1 to K do v1:=V[rand(1..nops(V))()]: v2:=V[rand(1..nops(V))()]: if v1<>v2 and HP(G,v1,v2)<>{} then RETURN([v1,v2]): fi: od: FAIL: end: #PlotHP(b,a,PA): plots the Hamiltonian Path PA in the m by n grid. Try: #gu:=HP(GG(4,4)):PlotHP(4,4,gu[1]): PlotHP:=proc(b,a,PA) local i,j,C1,C2,p: p:=plot([[0,0],[a,0],[a,b],[0,b],[0,0]],thickness=3,axes=none,scaling=constrained): for i from 1 to b-1 do p:=p,plot([[0,i],[a,i]]): od: for j from 1 to a-1 do p:=p,plot([[j,0],[j,b]]): od: for i from 1 to nops(PA)-1 do C1:=PA[i]: C2:=PA[i+1]: C1:=[C1[2]-1/2, b-C1[1]+1/2]: C2:=[C2[2]-1/2, b-C2[1]+1/2]: p:=p,plot([C1,C2],color=blue): od: display(p): end: #PlotP(PA): plots the Hamiltonian Path PA in the m by n grid. Try: #gu:=HP(GG(4,4)):PlotP(gu[1]): PlotP:=proc(PA) local i,C1,C2,p: C1:=PA[1]: C2:=PA[2]: p:=plot([C1,C2],axes=none,scaling=constrained): for i from 2 to nops(PA)-1 do C1:=PA[i]: C2:=PA[i+1]: p:=p,plot([C1,C2]): od: display(p): end: #AreNeis(pt1,pt2,C): given two lattice points in the dual graph of cells (given by their leftmost-bottom corner and a Hamiltonian cycle decides whether they #are both inside or both outside C. Try: #C:=HP(GG(4,3),[1,1],[1,2])[1]: AreNeis([1,1],[1,2],C); AreNeis:=proc(pt1,pt2,C) local gu,i: gu:={seq({C[i],C[i+1]},i=1..nops(C)-1),{C[nops(C)],C[1]}}: if pt2-pt1=[1,0] and member({pt2,pt2+[0,1]},gu) then RETURN(false): fi: if pt2-pt1=[-1,0] and member({pt1,pt1+[0,1]},gu) then RETURN(false): fi: if pt2-pt1=[0,1] and member({pt2,pt2+[1,0]},gu) then RETURN(false): fi: if pt1-pt2=[0,1] and member({pt1,pt1+[1,0]},gu) then RETURN(false): fi: true: end: #FindOneMore(m,n,C,S): Given a Hamiltonian cycle C of [1,m]x[1,n] starting at [1,1] and ending in [1,2] finds #and currently a set of cells inside the cycle, tries to find one more #or else returns FAIL. Try: #C:=HP(GG(4,3),[1,1],[1,2])[1]: FindOneMore(4,3,C,{[1,1]}); FindOneMore:=proc(m,n,C,S) local s,pt,lu,lu1: for s in S do lu:={[-1,0],[1,0],[0,-1],[0,1]}: for lu1 in lu do pt:=s+lu1: if 1<=pt[1] and pt[1]<=m-1 and 1<=pt[2] and pt[2]<=n-1 then if not member(pt,S) and AreNeis(s,pt,C) then RETURN(pt): fi: fi: od: od: FAIL: end: #FindOnes(m,n,C): Given positive integers m and n and a Hamiltonian cycle,C, in [1,m]x[1,n] finds all the cells inside C, #Try: #C:=HP(GG(4,3),[1,1],[1,2])[1]: FindOnes(4,3,C); FindOnes:=proc(m,n,C) local S,kha: S:={[1,1]}: kha:=FindOneMore(m,n,C,S): while kha<>FAIL do S:=S union {kha}: kha:=FindOneMore(m,n,C,S): od: S: end: #FindMatrix(m,n,C): Inputs positive integers m and n and a Hamiltonian cycle C of [1,m]x[1,n] outputs the corresponding (m-1)x(n-1) 0-1 matrix according to #Stoyan and Strehl. Try: #C:=HP(GG(4,3),[1,1],[1,2])[1]: FindMatix(4,3,C); FindMatrix:=proc(m,n,C) local S,i,j,T: S:=FindOnes(m,n,C): for i from 1 to m-1 do for j from 1 to n-1 do if member([i,j], S) then T[i,j]:=1: else T[i,j]:=0: fi: od: od: [seq([seq(T[i,n-j],i=1..m-1)],j=1..n-1)]: end: #AllMats(m,n): all the matrices corresponding to HP(GG(m,n),[1,1],[1,2]). Try: #AllMats(4,6); AllMats:=proc(m,n) local gu,gu1: gu:=HP(GG(m,n),[1,1],[1,2]): {seq(FindMatrix(m,n,gu1),gu1 in gu)}: end: #AreComp(u,v), are the 0-1 vectors u and v compatible in the sense of Stoyan-Strehl? Try: #AreComp([0,1],[1,0]); AreComp:=proc(u,v) local u1,v1,BAD,k: if nops(u)<>nops(v) then RETURN(FAIL): fi: BAD:={[[1,1],[1,1]],[[0,0],[0,0]],[[1,0],[0,1]],[[0,1],[1,0]]}: u1:=[0,op(u),0]: v1:=[0,op(v),0]: for k from 1 to nops(u1)-1 do if member([[u1[k],v1[k]],[u1[k+1],v1[k+1]]], BAD) then RETURN(false): fi: od: true: end: #IsGoodMat(M): Is the 0-1 matrix M good? Try: #IsGoodMat([[1,1,1,0,1],[0,0,1,0,1]]); IsGoodMat:=proc(M) local m,n,i: n:=nops(M): m:=nops(M[1]): if not AreComp([0$m],M[1]) then RETURN(false): fi: if not AreComp([0$m],M[n]) then RETURN(false): fi: for i from 1 to n-1 do if not AreComp(M[i],M[i+1]) then RETURN(false): fi: od: true: end: #VecToSP1(u): Given a 0-1 vector finds the set of connected componets of the places where there 1's. Try: #VecToSP1([1,0,1,0]); VecToSP1:=proc(u) local i,j,k,S: for i from nops(u) to 1 by -1 while u[i]=0 do od: if i=0 then RETURN({}): fi: for j from i to 1 by -1 while u[j]=1 do od: S:={seq(k,k=j+1..i)}: if S={seq(k,k=1..nops(u))} then RETURN({S}): fi: {op(VecToSP1([op(1..j,u)])),S}: end: #IsMate(S1,S2,SP): is a set in SP that intersects both S1 and S2? Try #IsMate({1,2,3},{5,6},[{3,4,5},{7,8}]); IsMate:=proc(S1,S2,SP) local i: for i from 1 to nops(SP) do if S1 intersect SP[i]<>{} and S2 intersect SP[i]<>{} then RETURN(true): fi: od: false: end: #GtoN(G): inputs a graph G=[V,E] and outputs [G,TableOfNeigbors]. Try: #GtoN([{1,2,3},{{1,2},{1,3}}]); GtoN:=proc(G) local V,E,T,e,v: option remember: V:=G[1]: E:=G[2]: for v in V do T[v]:={}: od: for e in E do T[e[1]]:=T[e[1]] union {e[2]}: T[e[2]]:=T[e[2]] union {e[1]}: od: [V,op(T)]: end: #CC1(G,i): The connected component of vertex i in the graph G CC1:=proc(G,i) local N,V,gu1,gu2,v,T: N:=GtoN(G): V:=N[1]: if not member(i,V) then RETURN(FAIL): fi: T:=N[2]: gu1:={i}: gu2:=gu1 union {seq(op(T[v]),v in gu1)}: while gu1<>gu2 do gu1:=gu2: gu2:=gu2 union {seq(op(T[v]),v in gu2)}: od: gu2: end: #CC(G): The set of connected components of G CC:=proc(G) local i: {seq(CC1(G,i), i in G[1])}: end: #IndSP(SP1,SP2): Given two set-partitions SP1, SP2, makes SP2 possibly smaller by joining any two sets that intersect the same set in SP1. Try: #IndSP([{2,3,4},{6,7}],[{1,2},{4,5},{7,8,9}]); IndSP:=proc(SP1,SP2) local G,i,j,SP,k,v: G:={}: for i from 1 to nops(SP2) do for j from i+1 to nops(SP2) do if IsMate(SP2[i],SP2[j],SP1) then G:=G union {{i,j}} fi: od: od: SP:=CC([{seq(k,k=1..nops(SP2))},G]): {seq({seq(op(SP2[v]), v in SP[k])},k=1..nops(SP))}: end: #MatToW(M): Given a 0-1 matrix finds the corresponding word in the Stoyan-Strehl alphabet #Try: #gu:=AllMats(4,6); MatToW(gu[1]); MatToW:=proc(M) local W,i,SPn: W:=[[M[1],VecToSP1(M[1])]]: for i from 2 to nops(M) do SPn:=VecToSP1(M[i]): SPn:=IndSP(W[i-1][2],SPn): W:=[op(W),[M[i],SPn]]: od: W: end: #Vecs(n): The set of all 0-1 vectors of length n. Try: #Vecs(4); Vecs:=proc(n) local gu,gu1: option remember: if n=0 then RETURN({[]}): fi: gu:=Vecs(n-1): {seq([op(gu1),0],gu1 in gu), seq([op(gu1),1],gu1 in gu)}: end: #Starters(n): All the possible starting letters of binary vectors of length n. Try: #Starters(4); Starters:=proc(n) local mu,mu1,gu: gu:={}: mu:=Vecs(n): for mu1 in mu do if AreComp([0$n],mu1) then gu:=gu union {[mu1,VecToSP1(mu1)]}: fi: od: gu: end: #Enders(n): All the possible ending letters of binary vectors of length n. Try: #Enders(4); Enders:=proc(n) local mu,mu1,gu,ku,i1: gu:={}: mu:=Vecs(n): for mu1 in mu do if AreComp(mu1,[0$n]) then ku:=VecToSP1(mu1): ku:={{seq(op(ku[i1]),i1=1..nops(ku))}}: gu:=gu union {[mu1,ku]}: fi: od: gu: end: #Followers(W1): Inputs a letter in the Stoyan-Strehl alphabet, outputs all the followers. Try: #Followers([[1,1,1],{{1,2,3}}]); Followers:=proc(W1) local n,mu,mu1,gu,ku,ju: n:=nops(W1[1]): mu:=Vecs(n) minus {[0$n]} : gu:={}: for mu1 in mu do if AreComp(W1[1],mu1) then ju:=VecToSP1(mu1): ku:=IndSP(W1[2],ju): if not HasCycle(W1[2],ju) and AreCon( W1[2], ku) then gu:=gu union {[mu1,ku ]}: fi: fi: od: gu minus {[[0$n],{}]}: end: #AlphaSS(n): All the letters in the Stoyan-Strehl alphabet of length n. Try: #AlphaSS(3); AlphaSS:=proc(n) local gu1,gu2,gu11: gu1:=Starters(n): gu2:=gu1 union {seq(op(Followers(gu11)),gu11 in gu1)}: while gu1<>gu2 do gu1:=gu2: gu2:=gu2 union {seq(op(Followers(gu11)),gu11 in gu1)}: od: gu2 minus {[[0$n],{}]}: end: #AreCon(SP1,SP2): Given two set partitions SP1 and SP2 is each component of SP2 connected to some component of SP1? #Try: #AreCon({{1}},{{3}}); AreCon:=proc(SP1,SP2) local gu1,kv2,i: kv2:={seq(op(SP2[i]),i=1..nops(SP2))}: for gu1 in SP1 do if gu1 intersect kv2={} then RETURN(false): fi: od: true: end: #GFnz(n,z): The rational function whose coefficient of z^m is the number of Hamiltonian cycles in the grid graph [n+1]x[m+1]. Try: #GFnz(3,z); GFnz:=proc(n,z) local eq,var,eq1,AL,St,X,mu1,lu,lu1,En: St:=Starters(n-1): En:=Enders(n-1): AL:=AlphaSS(n-1): if not St minus AL={} then print(`Something bad happened`): RETURN(FAIL): fi: var:={seq(X[mu1], mu1 in AL)}: eq:={}: for mu1 in AL do if member(mu1,En) then eq1:=X[mu1]-z: else eq1:=X[mu1]: fi: lu:=Followers(mu1): eq1:=eq1-z*add(X[lu1],lu1 in lu): eq:=eq union {eq1}: od: var:=solve(eq,var): normal(z*add(subs(var,X[mu1]), mu1 in St)): end: #EmpAlp1(m,n): The first letters, all letters, and final letters of words in AllMats(n,m). Try: #EmpAlp1(4,6); EmpAlp1:=proc(m,n) local gu,gu1: gu:=AllMatsF(m,n): gu:={seq(MatToW(gu1),gu1 in gu)}: [{seq(gu1[1],gu1 in gu)},{seq(op(gu1),gu1 in gu)},{seq(gu1[-1],gu1 in gu)}]: end: EmpAlpA:=proc(m) local n: if m mod 2=0 then for n from 2 while EmpAlp1(m,n)<>EmpAlp1(m,n+1) do od: RETURN(EmpAlp1(m,n+1)): fi: for n from 2 by 2 while EmpAlp1(m,n)<>EmpAlp1(m,n+2) do od: RETURN(EmpAlp1(m,n+2)): end: EmpAlp:=proc(m): EmpAlpA(m+1):end: #FollowersEt(n,m): The follower table for EmpAlp(n) does empirically. Try: #FollowersEt(3,6); FollowersEt:=proc(n,m) local mu,gu,T,mu1,gu1,i: option remember: mu:=EmpAlp(n)[2]: for mu1 in mu do T[mu1]:={}: od: gu:=AllMatsF(n+1,m+1): gu:={seq(MatToW(gu1),gu1 in gu)}: for gu1 in gu do for i from 1 to nops(gu1)-1 do T[gu1[i]]:= T[gu1[i]] union {gu1[i+1]}: od: od: op(T): end: FollowersE:=proc(W1) local n: n:=nops(W1[1]): if n mod 2=1 then FollowersEt(n,6)[W1]: else FollowersEt(n,7)[W1]: fi: end: #GFnzE(n,z): The rational function whose coefficient of z^m is the number of Hamiltonian cycles in the grid graph [n+1]x[m+1]. Try: #GFnzE(3,z); GFnzE:=proc(n,z) local eq,var,eq1,AL,St,X,mu1,lu,lu1,gu: gu:=EmpAlp(n): St:=gu[1]: AL:=gu[2]: if not St minus AL={} then print(`Something bad happened`): RETURN(FAIL): fi: var:={seq(X[mu1], mu1 in AL)}: eq:={}: for mu1 in AL do if member(mu1,gu[3]) then eq1:=X[mu1]-z: else eq1:=X[mu1]: fi: lu:=FollowersE(mu1): eq1:=eq1-z*add(X[lu1],lu1 in lu): eq:=eq union {eq1}: od: var:=solve(eq,var): normal(add(subs(var,X[mu1]), mu1 in St)): end: #FollowersM(M): Given a 0-1 matrix M finds all the legal followers . Try: #FollowersM([[1,0,1]]); FollowersM:=proc(M) local a,b,M1,C,gu,v: a:=nops(M): b:=nops(M[1]): C:=Vecs(b) minus {[0$b]}: gu:={}: for v in C do if AreComp(M[a],v) then M1:=[op(M),v]: if IsForest(M1) then gu:=gu union {M1}: fi: fi: od: gu: end: #AllMatsF1(m,n): All (n-1)x(m-1) matrices such that the ones form a forest. A superset of AllMats(m,n), but done faster. Try: #AllMatsF1(4,6); AllMatsF1:=proc(m,n) local a,b,gu,gu1,C,v: option remember: a:=n-1: b:=m-1: if a=1 then gu:={}: C:=Vecs(b) minus {[0$b]}: for v in C do if AreComp([0$b],v) then gu:=gu union {[v]}: fi: od: RETURN( gu): fi: gu:=AllMatsF1(m,n-1): {seq(op(FollowersM(gu1)),gu1 in gu)}: end: #AllMatsF(m,n): A faster way of doing AllMats(m,n). Try: #AllMatsF(4,6); AllMatsF:=proc(m,n) local a,b,mu,mu1,gu: a:=n-1: b:=m-1: mu:=AllMatsF1(m,n): gu:={}: for mu1 in mu do if IsTree(mu1) and AreComp(mu1[-1],[0$b]) then gu:=gu union {mu1}: fi: od: gu: end: #HasCycle1(SP1,SP2): inputs a formet set partition SP1 and a virgin set parition SP2 finds out whether putting SP2 on top on SP1 formes a cycle with one bridge. Try: #HasCycle1({{1,3}},{{1,2,3}}); HasCycle1:=proc(SP1,SP2) local gu1,gu2: for gu1 in SP1 do for gu2 in SP2 do if nops(gu2)>=2 and nops(gu1)>=2 and nops(gu1 intersect gu2)>=2 then RETURN(true): fi: od: od: false: end: #AllWords1(m,n):The mapping of prefixes AllMats(m,n). Try: #AllWords1(4,4); AllWords1:=proc(m,n) local a,b,lu,lu1,ru,ru1,gu: option remember: a:=m-1: b:=n-1: if b=1 then lu:=Starters(a): RETURN({seq([lu1],lu1 in lu)}): fi: lu:=AllWords1(m,n-1): gu:={}: for lu1 in lu do ru:=Followers(lu1[-1]): gu:=gu union {seq([op(lu1),ru1],ru1 in ru)}: od: gu: end: #AllWords(m,n): the maps of AllMats(m,n) AllWords:=proc(m,n) local sof,mu,mu1,gu: sof:=Enders(m-1): mu:=AllWords1(m,n): gu:={}: for mu1 in mu do if member(mu1[-1], sof) then gu:=gu union {mu1}: fi: od: gu: end: #ConTable(SP1,SP2): inputs a set parition SP1 and a virgin set partition SP2, outputs a table #defined on the members of SP2 indicationg the set of members of SP1 it intersects with it. #Try: ConTable({{1,2,3,9},{5,6,7}}, {{3,4,5},{7,8,9}}); ConTable:=proc(SP1,SP2) local T,i,j: for i from 1 to nops(SP2) do T[SP2[i]]:={}: for j from 1 to nops(SP1) do if SP2[i] intersect SP1[j]<>{} then T[SP2[i]]:=T[SP2[i]] union {SP1[j]}: fi: od: od: op(T): end: #HasCycle2(SP1,SP2): inputs a formet set partition SP1 and a virgin set parition SP2 finds out whether putting SP2 on top on SP1 formes a cycle with at least two bridges. Try: #HasCycle2({{1,2,3,10},{5,6,7}},{{2,3,4,5}, {7,8,9,10}}); HasCycle2:=proc(SP1,SP2) local T,i,j: T:=ConTable(SP1,SP2): for i from 1 to nops(SP2) do for j from i+1 to nops(SP2) do if nops(T[SP2[i]] intersect T[SP2[j]])>=2 then RETURN(true): fi: od: od: false: end: #HasCycle(SP1,SP2): inputs a formet set partition SP1 and a virgin set parition SP2 finds out whether putting SP2 on top on SP1 formes a cycle HasCycle:=proc(SP1,SP2): HasCycle1(SP1,SP2) or HasCycle2(SP1,SP2):end: #Paper1(M,N1,z): an article with the generating functions for enumerating the number of Hamiltonian cycles in grid graphs [m]x[n] for m from 2 to M #it also returns the first N1 terms Paper1:=proc(M,N1,z) local gu,m,mu,i,L,t0: t0:=time(): L:=[]: print(`The Generating Functions for Enumerating the Number of Hamiltonian Cycles in grid graphs [n]x[m] for m from 2 to`, M): print(``): print(`By Shalosh B. Ekhad `): print(``): for m from 2 to M do gu:=GFnzPC(m,z): L:=[op(L),gu]: print(``): print(`For m= `, m, `the generating function is`): print(``): lprint(gu): print(``): mu:=taylor(gu,z=0,N1+5): print(``): print(`The first`, N1, `terms are `): print(``): lprint([seq(coeff(mu,z,i),i=1..N1)]): print(``): od: print(``): print(`-------------------`): print(``): print(`To sum up here are the first`, M-1, `generating functions starting with m=2 all the way to m=`,M): print(``): lprint(L): print(``): print(`-------------------`): print(``): print(`This took`, time()-t0, `seconds.`): end: #SSdg(m): The directed graph,G, corresponding to Hamiltonian cycles on [m]x[n] with a fixed m, using the Stoyan-Strehl approach #vertex 1 is the START denoted by 1, and vertex nops(G) is the END denoted by SizeOfAlphabet+2 and the actual alphabet is of size nops(G)-2 and coincides with AlphaSS(m) #It also outputs the dictionary. Try: #SSdg(3); SSdg:=proc(m) local gu1,gu2,gu3,T,i,E,s,S,n: gu1:=Starters(m): gu2:=convert(AlphaSS(m),list): n:=nops(gu2): gu2:=[1,op(gu2),n+2]: for i from 2 to n+1 do T[gu2[i]]:=i: od: gu1:=Starters(m): gu3:=Enders(m): E:=[{seq(T[s], s in gu1)}]: gu3:=Enders(m): for i from 2 to n+1 do S:=Followers(gu2[i]): S:={seq(T[s], s in S)}: if member(gu2[i],gu3) then S:=S union {n+2}: fi: E:=[op(E),S]: od: E:=[op(E),{}]: [E,gu2]: end: #WtLetter(L): The weight in terms of w of the letter L in AlphaSS(m) WtLetter:=proc(L,w) local i:mul(w[i]^L[1][i],i=1..nops(L[1])):end: #GFnzG(n,z,w): The rational function whose coefficient of z^m is the weight-enumerator of Hamiltonian cycles in the grid graph [n]x[m] according to the number of 1's in each of the n columns of #the associated matrices. Try: #GFnzG(3,z,w); GFnzG:=proc(n,z,w) local eq,var,eq1,AL,St,X,mu1,lu,lu1,En: St:=Starters(n-1): En:=Enders(n-1): AL:=AlphaSS(n-1): if not St minus AL={} then print(`Something bad happened`): RETURN(FAIL): fi: var:={seq(X[mu1], mu1 in AL)}: eq:={}: for mu1 in AL do if member(mu1,En) then eq1:=X[mu1]-z*WtLetter(mu1,w): else eq1:=X[mu1]: fi: lu:=Followers(mu1): eq1:=eq1-z*WtLetter(mu1,w)*add(X[lu1],lu1 in lu): eq:=eq union {eq1}: od: var:=solve(eq,var): normal(z*add(subs(var,X[mu1]), mu1 in St)): end: #Paper2(M,N1,z,w): an article with the generating functions for weight-enumerating the Hamiltonian cycles in grid graphs [n]x[m] for m from 2 to M #according to the weight "Number of 1s in the n columns of the associated matrix #it also returns the first N1 terms Paper2:=proc(M,N1,z,w) local gu,m,mu,i,L,t0: t0:=time(): L:=[]: print(`The Generating Functions for Weight-Enumerating the Set of Hamiltonian Cycles in grid graphs [n]x[m] for m from 2 to`, M, `according to the number of cells inside the curve in the various Columns `): print(``): print(`By Shalosh B. Ekhad `): print(``): for m from 2 to M do gu:=GFnzG(m,z,w): L:=[op(L),gu]: print(``): print(`For m= `, m, `the weighted-generating function is`): print(``): lprint(gu): print(``): mu:=taylor(gu,z=0,N1+5): print(``): print(`The first`, N1, `terms are `): print(``): lprint([seq(expand(coeff(mu,z,i)),i=1..N1)]): print(``): od: print(``): print(`-------------------`): print(``): print(`To sum up here are the first`, M-1, `weighted generating functions starting with m=2 all the way to m=`,M): print(``): lprint(L): print(``): print(`-------------------`): print(``): print(`This took`, time()-t0, `seconds.`): end: #RandHP(m,n): A random Hamiltonian path in the Grid-Graph [n]x[m]. Try: #RandHP(4,6); RandHP:=proc(m,n) local G,Di,W,i1: G:=SSdg(m-1): Di:=G[2]: G:=G[1]: W:=RandW(G,1,nops(G),n): AntiFindMatrix([seq(Di[W[i1]][1],i1=2..nops(W)-1)]): end: ###From Stat #Stat(F,t,K): Given a generating function F of t, for a r.v. # finds the statistical information Stat:=proc(F,t,K) local gu,mu,sd,k,f: f:=evalf(F/subs(t=1,F),20): mu:=subs(t=1,diff(f,t)): gu:=[mu]: if K=1 then RETURN(gu): fi: f:=f/t^mu: f:=t*diff(t*diff(f,t),t): sd:=sqrt(subs(t=1,f)): gu:=[op(gu),sd]: for k from 3 to K do f:=t*diff(f,t): gu:=[op(gu),subs(t=1,f)/sd^k]: od: evalf(gu,20): end: #### #SumCol(M,j): Inputs a 0-1 matrix with nops(M[1]) columns, outputs the sum of the j-th column. Try: #SumCol([[a1,a2,a3],[b1,b2,b3]],2); SumCol:=proc(M,j) local i:add(M[i][j],i=1..nops(M)):end: #CheckRandHP(m,n,c,K,K1): Checks RandHP(m,n) by comparing the empirical statistics to the exact one regarding the #number of 1's in the associated Stoyan-Strehl 0-1 matrix (number of cells contained INSIDE the circuit) #in the c-th column. It compares the empirical average, standad-deviation and the scaled moments up to the K1. Try: #CheckRandHP(4,20,1,100,K1,4); CheckRandHP:=proc(m,n,c,K,K1) local fE,fA,w,z,i: if not (c>=1 and c<=m-1) then RETURN(FAIL): fi: fE:=GFnzG(m,z,[1$(c-1),w,1$(m-1-c)]): fE:=expand(coeff(taylor(fE,z=0,n+5),z,n)): fA:=add(w^SumCol(FindMatrix(m,n,RandHP(m,n)),c),i=1..K)/K: [Stat(fE,w,K1), Stat(fA,w,K1)]: end: #Paper3(M,n1,K,K1): A paper listing CheckRandHP(m,n,c,K,K1) for picking a random Hamiltonian cycle of the grid graph [n]x[m], where n must be even, for all #m from 3 to M and all columns,c, from 1 to m-1. Try: #Paper3(6,200,100,4); Paper3:=proc(M,n1,K,K1) local n,L,c,m,t0: t0:=time(): if n mod 2=1 then print(n, `is not even `): RETURN(FAIL): fi: print(`Testing the procedure for Random Generation of Hamiltonian Paths of the grid graph [n]x[m] for`, n=n1, `and m from 3 to`, M, `By sampling`, K, `times `): print(``): print(`By Shalosh B. Ekahd`): for m from 3 to M do for c from 1 to m-1 do L:=CheckRandHP(m,n1,c,K,K1): print(``): print(`For the grid graph `, n1, ` by `, m, `and column `, c, `the exact average, standard deviation and the scaled moments up to`, K1, ` for the number of 1s in the associated 0-1 matrix are `): print(): lprint(L[1]): print(): print(`While the estimates, based on simulating it`, K, `times is `): print(): lprint(L[2]): print(``): od: od: print(`------------------------------------------`): print(``): print(`This took`, time()-t0, `seconds. `): print(``): end: ###start Asymptotics #Asy1E(f,z): Given a rational function f whose denominator has no multiple roots, finds [C,alpha] such that #the coeff. of z^n is C*alpha^n. Try: #Asy1E((z^2+1)/(1-z-z^2),z); Asy1E:=proc(f,z) local f1,P,Q,lu,aluf,si,i,hal,A: f1:=factor(f): P:=numer(f1): Q:=denom(f1): if type(Q,`^`) then RETURN(FAIL): fi: lu:=[solve({Q},{z})]: aluf:=subs(lu[1],z): si:=abs(evalf(subs(lu[1],z))): for i from 2 to nops(lu) do hal:=abs(evalf(subs(lu[i],z))): if hal10^(-Digits-2) then RETURN(FAIL): fi: aluf:= aluf1: C1:=coeff(f1,z,K)/aluf^K: C2:=coeff(f1,z,K-1)/aluf^(K-1): if abs(C1-C2)>10^(-Digits-2) then RETURN(FAIL): fi: evalf([C1,aluf]): end: #AsyAve(f,z,w,K): inputs a rational function f in z and w estiamtes [C1,C0] such that the coeff. of z^n of subs(w=1,diff(f,w)) divided by the coeff. of z^n equals C1*n+C0 by looking #at two consectutive terms around the coeff. of z^K. Try: #AsyAve(1/(1-z*w-z^2),z,w,200); AsyAve:=proc(f,z,w,K) local eq,var,C1,C0,f0,f1,f0T,f1T,C0a,C1a,C0b, C1b,sol,i: f0:=normal(subs(w=1,f)): f1:=normal(subs(w=1,diff(f,w))): f0T:=taylor(f0,z=0,K+10): f1T:=taylor(f1,z=0,K+10): var:={C0,C1}: eq:={seq(coeff(f1T,z,i)/coeff(f0T,z,i)=C0+C1*i,i=K-3..K-2)}: sol:=solve(eq,var): C0a:=subs(sol,C0): C1a:=subs(sol,C1): eq:={seq(coeff(f1T,z,i)/coeff(f0T,z,i)=C0+C1*i,i=K-1..K)}: sol:=solve(eq,var): C0b:=subs(sol,C0): C1b:=subs(sol,C1): if abs(C0a-C0b)>10^(-Digits-2) or abs(C1a-C1b)>10^(-Digits-2) then RETURN(FAIL): fi: evalf([C1b,C0b]): end: #AsyM2(f,z,w,K): inputs a rational function f in z and w estiamtes [C2,C1,C0] such that the coeff. of z^n of subs(w=1,diff(w*diff(f,w),w)) divided by the coeff. of z^n equals C2*n^2+C1*n+C0 by looking #at two consectutive terms around the coeff. of z^K. Try: #AsyM2(1/(1-z*w-z^2),z,w,200); AsyM2:=proc(f,z,w,K) local eq,var,C1,C0,f0,f1,f0T,f1T,C0a,C1a,C0b, C1b,sol,i,C2,C2a,C2b: f0:=normal(subs(w=1,f)): f1:=normal(subs(w=1,diff(w*diff(f,w),w))): f0T:=taylor(f0,z=0,K+10): f1T:=taylor(f1,z=0,K+10): var:={C0,C1,C2}: eq:={seq(coeff(f1T,z,i)/coeff(f0T,z,i)=C0+C1*i+C2*i^2,i=K-5..K-3)}: sol:=solve(eq,var): C0a:=subs(sol,C0): C1a:=subs(sol,C1): C2a:=subs(sol,C2): eq:={seq(coeff(f1T,z,i)/coeff(f0T,z,i)=C0+C1*i+C2*i^2,i=K-2..K)}: sol:=solve(eq,var): C0b:=subs(sol,C0): C1b:=subs(sol,C1): C2b:=subs(sol,C2): if abs(C0a-C0b)>10^(-Digits-2) or abs(C1a-C1b)>10^(-Digits-2) or abs(C2a-C2b)>10^(-Digits-2) then RETURN(FAIL): fi: evalf([C2b,C1b,C0b]): end: #AsyM11(f,z,w1,w2,K): inputs a rational function f in z and w estiamtes [C2,C1,C0] such that the coeff. of z^n of subs({w1=1,w2=1},w2*diff(w1*diff(f,w1),w2)) divided by the coeff. of z^n equals C2*n^2+C1*n+C0 by looking #at two consectutive terms around the coeff. of z^K. Try: #AsyM11(1/(1-z*w1-z^2*w2),z,w1,w2,200); AsyM11:=proc(f,z,w1,w2,K) local eq,var,C1,C0,f0,f1,f0T,f1T,C0a,C1a,C0b, C1b,sol,i,C2,C2a,C2b: f0:=normal(subs({w1=1,w2=1},f)): f1:=normal(subs({w1=1,w2=1},w2*diff(w1*diff(f,w1),w2))): f0T:=taylor(f0,z=0,K+10): f1T:=taylor(f1,z=0,K+10): var:={C0,C1,C2}: eq:={seq(coeff(f1T,z,i)/coeff(f0T,z,i)=C0+C1*i+C2*i^2,i=K-5..K-3)}: sol:=solve(eq,var): C0a:=subs(sol,C0): C1a:=subs(sol,C1): C2a:=subs(sol,C2): eq:={seq(coeff(f1T,z,i)/coeff(f0T,z,i)=C0+C1*i+C2*i^2,i=K-2..K)}: sol:=solve(eq,var): C0b:=subs(sol,C0): C1b:=subs(sol,C1): C2b:=subs(sol,C2): if abs(C0a-C0b)>10^(-Digits-2) or abs(C1a-C1b)>10^(-Digits-2) or abs(C2a-C2b)>10^(-Digits-2) then RETURN(FAIL): fi: evalf([C2b,C1b,C0b]): end: #AsyVar(f,z,w,K): inputs a rational function f in z and w where the coeff. of z^n is the weight-enumerator of some statistics on the set A_n #outputs [C1,C2] such that the varaince is asymptotically is C1*n+C2 #AsyVar(1/(1-z*w-z^2),z,w,200); AsyVar:=proc(f,z,w,K) local n,lu1,lu2,gu: lu1:=AsyAve(f,z,w,K): if lu1=FAIL then RETURN(FAIL): fi: lu2:=AsyM2(f,z,w,K): if lu2=FAIL then RETURN(FAIL): fi: gu:=expand(lu2[1]*n^2+lu2[2]*n+lu2[3]- (lu1[1]*n+lu1[2])^2): if abs(coeff(f,n,2))>1/10^(Digits-3) then RETURN(FAIL): fi: [coeff(gu,n,1),coeff(gu,n,0)]: end: #end asymptotics #Paper4(M,K,z,w): A paper listing the generating function for weighted-enumerating Hamiltonian cycles in [n]x[m] according to the number of edges in the left-most side of the grid #m from 3 to M. K is a parameter for the numerics, and should be at least 400. #Paper4(6,500,z,w); Paper4:=proc(M,K,z,w) local m,lu,f0,f,n,t0: t0:=time(): print(`Weighted Counting According to the Number of Edges in the Left Border of Hamiltonian Cycles in n by m Rectangular Grids, for m from 3 to`, M): print(``): print(`By Shalosh B. Ekahd`): print(``): print(`If m is odd let P_{n,m}(w) be the weight-enumerator according to the number of edges in the left border of a Hamiltonian cycle of an 2*n by m`): print(``): print(`If m is even let P_m(w) be the weight-enumerator according to the number of edges in the left border of a Hamiltonian cycle of an n by m`): print(``): print(`For a Hamiltonian cycle C, Let LeftEdges(C) be the random variable: Number of edges of the Cycle on the left border of the rectangle `): print(``): for m from 3 to M do print(``): f:=GFnzG(m,z,[w,1$(m-2)]): print(``): if m mod 2=1 then f:=subs(z=sqrt(z),f): fi: f0:=normal(subs(w=1,f)): print(Sum(P[m,n](1)*z^n,n=0..infinity)): print(``): print(` equals `): print(``): print(f0): print(``): print(`and in Maple notation`): print(``): lprint(f0): print(``): lu:=Asy1E(f0,z,K): if m mod 2=0 then print(`The number of Hamiltonian cycles in an `, m, ` by n grid is`): print(``): lprint(lu[1]*lu[2]^n): else print(`The number of Hamiltonian cycles in an `, m, ` by 2*n grid is`): print(``): lprint(lu[1]*lu[2]^n): fi: lu:=AsyAve(f,z,w,K): if m mod 2=0 then print(`The asymptotic expression, in n, for the average of the number of edges that the Hamiltonian circuits shares with the left border for `, m, ` by n grids is`): print(``): else print(`The asymptotic expression, in n, for the average of the number of edges that the Hamiltonian circuits shares with the left border for `, m, ` by 2n grids is`): print(``): fi: lprint(lu[1]*n+lu[2]): lu:=AsyVar(f,z,w,K): print(``): if m mod 2=0 then print(``): print(`The asymptotic expression, in n, for the varaince of the number of edges that the Hamiltonian circuits shares with the left border for `, m, ` by n grids is`): else print(``): print(`The asymptotic expression, in n, for the variance of the number of edges that the Hamiltonian circuits shares with the left border for `, m, ` by 2n grids is`): fi: print(``): lprint(lu[1]*n+lu[2]): print(`--------------------------------------------------`): print(``): od: print(`------------------------------------------------------`): print(``): print(`This ends this paper, that took`, time() -t0, `seconds to produce `): print(``): end: #AsyCov(f,z,w1,w2,K): inputs a rational function f in z, w1 and w2, where the coeff.of z^n is the bi-variate weight-enumerator of some bi-statistic defined on the combinatorial set A_n (in the combinatorial family) #outputs [C1,C2] such that the covariance is asymptotically is C1*n+C2 #AsyCov(1/(1-z*w1-w2*z^2),z,w1,w2,500); AsyCov:=proc(f,z,w1,w2,K) local n,lu1a,lu1b,lu2,gu: lu1a:=AsyAve(subs(w2=1,f),z,w1,K): if lu1a=FAIL then RETURN(FAIL): fi: lu1b:=AsyAve(subs(w1=1,f),z,w2,K): if lu1b=FAIL then RETURN(FAIL): fi: lu2:=AsyM11(f,z,w1,w2,K): if lu2=FAIL then RETURN(FAIL): fi: gu:=expand(lu2[1]*n^2+lu2[2]*n+lu2[3]- (lu1a[1]*n+lu1a[2])*(lu1b[1]*n+lu1b[2])): if abs(coeff(f,n,2))>1/10^(Digits-3) then RETURN(FAIL): fi: [coeff(gu,n,1),coeff(gu,n,0)]: end: #AsyCor(f,z,w1,w2,K): inputs a rational function f in z, w1 and w2, where the coeff.of z^n is the bi-variate weight-enumerator of some bi-statistic defined on the combinatorial set A_n (in the combinatorial family) #outputs the asympototic correlation. Try: #AsyCor(1/(1-z*w1-w2*z^2),z,w1,w2,500); AsyCor:=proc(f,z,w1,w2,K) local lu1,lu2a,lu2b: lu1:=AsyCov(f,z,w1,w2,K)[1]: if lu1=FAIL then RETURN(FAIL): fi: lu2a:=AsyVar(subs(w1=1,f),z,w2,K)[1]: if lu2a=FAIL then RETURN(FAIL): fi: lu2b:=AsyVar(subs(w2=1,f),z,w1,K)[1]: if lu2b=FAIL then RETURN(FAIL): fi: lu1/sqrt(lu2a*lu2b): end: #Paper5(M,K): A paper listing the asympotic correlation (as n goes to innfinity) between the number of edges visited in the left border and right border of the grid [n]x[m] #also between the number of 1's in the associated Stoyan-Strehl 0-1 matrix in the first and second columns. #m from 3 to M. K is a parameter for the numerics, and should be at least 400. Try #Paper5(6,500); Paper5:=proc(M,K) local f,m,z,w1,w2,lu,t0: t0:=time(): print(`The limits of the Correlation coefficients (as n goes to infinity) between the number od edges visited in the left norder and the right border of random Hamiltonian Cycles in the rid graph [n]x[m]for m from 3 to`, M): print(``): print(`By Shalosh B. Ekahd`): print(``): for m from 3 to M do print(``): print(`For the n by `, m, ` grid, the limit of the correlation coefficient of the number of edges visited on the left border and the right border is`): f:=GFnzG(m,z,[w1,1$(m-3),w2]): if m mod 2=1 then f:=subs(z=sqrt(z),f): fi: lu:=AsyCor(f,z,w1,w2,K): if lu=FAIL then RETURN(FAIL): else lprint(lu): fi: od: for m from 3 to M do print(``): print(`For the n by`, m, ` grid, the limit of the correlation coefficient of the number of 1s in the first and second columns of the asociated Stoyan-Strehl 0-1 matrix is`): f:=GFnzG(m,z,[w1,w2,1$(m-3)]): if m mod 2=1 then f:=subs(z=sqrt(z),f): fi: lu:=AsyCor(f,z,w1,w2,K): if lu=FAIL then RETURN(FAIL): else lprint(lu): fi: od: print(``): print(`------------------------`): print(``): print(`This took`, time()-t0, `seconds. `): print(``): end: