######################################################################
##Gessel64: Save this file as  Gessel64                              #
## To use it, stay in the                                            #
##same directory, get into Maple (by typing: maple <Enter> )         #
##and then type:  read Gessel64<Enter>                               #
##Then follow the instructions given there                           #
##                                                                   #
##Written by Nathaniel Shar and Doron Zeilberger, Rutgers University #
#zeilberg at math dot rutgers dot edu                                #
######################################################################
 
#Created:  April 2015
#This version: June 23, 2015 (adding procedure LeadingIra)
 
print(`Created:  April, 2015`):
print(`This version: June 23, 2015 (adding procedure LeadingIra)`):
print(` This is Gessel64 `):
print(`It is a Maple package that accompanies the article `):
print(`The number of 1...d-avoding permutations of length d+r for symbolic d and numeric r`):
print(`by Shalosh B. Ekhad, Nathaniel Shar, and Doron Zeilberger`):
print(`dedicated to Ira Martin Gessel (b. April 9, 2015) on his 64th birthday. `):
print(`This paper is available from Zeilberger's website.`):
print(``):
print(`Please report bugs to zeilberg at math dot rutgers dot edu`):
print(``):
 print(`The most current version of this  package and paper`):
 print(` are  available from`):
 print(`http://www.math.rutgers.edu/~zeilberg/  .`):

print(`---------------------------------------`):
 print(`For a list of the Supporting procedures type ezra1();, for help with`):
 print(`a specific procedure, type ezra(procedure_name);   .`):
 print(``):
print(`---------------------------------------`):

print(`---------------------------------------`):
 print(`For a list of the MAIN procedures type ezra();, for help with`):
 print(`a specific procedure, type ezra(procedure_name);   .`):
 print(``):
print(`---------------------------------------`):

with(combinat):

ezra1:=proc()

if args=NULL then
 print(` The supporting procedures are: detD, detTP, detTPD, GesselMat, GuessPol, Iv, Hook, Partition, RanMatN, RanMatP,  SeqIraD, Wt1 `):
 print(``):

else
ezra(args):
fi:

end:

ezra:=proc()

if args=NULL then
 print(`The main procedures are: A, Apc, Avoi,AvoiPC,  LeadingIra, LeadingIraV, Mamar, MamarSeq, SeqA, SeqApc,  SeqIra  `):
 print(` `):



elif nops([args])=1 and op(1,[args])=A then
print(`A(d,r): inputs a symbol d and a  positive integer r, and outputs an explicit expression for`):
print(`the number of 1...d-CONTAINING permutations of length d+r. Try:`):
print(`A(d,2);`):

elif nops([args])=1 and op(1,[args])=Apc then
print(`Apc(d,r): Precomputed version of A(d,r) (q.v). For r<=30 it returns the precomputed value of A(d,r) hence is much faster.`):
print(`for r>30 it just calls A(d,r). Try:  `):
print(`Apc(d,29);`):

elif nops([args])=1 and op(1,[args])=Avoi then
print(`Avoi(n,k): the number of 1...k-avoiding permutations of length n. Try`):
print(`Avoi(7,4);`):

elif nops([args])=1 and op(1,[args])=AvoiPC then
print(`AvoiPC(n,k): the number of 1...k-avoiding permutations of length n. For k<=30 it uses pre-comuted expressions for A(d,k) . Try`):
print(`AvoiPC(7,4);`):

elif nops([args])=1 and op(1,[args])=detD then
print(`detD(A): the determinant of A using Dodgson's rule `):
print(` try: `):
print(` detD([[1,2,3],[2,3,4],[3,4,5]]); `):

elif nops([args])=1 and op(1,[args])=detTP then
print(`detTP(M,t,N): the determinant of the matrix M of polynomials in the variable t truncated to the t^N `):
print(` done directly. Try: `):
print(` detTP(GesselMat(5,t,30),t,60); `):

elif nops([args])=1 and op(1,[args])=detTPD then
print(`detTPD(A,t,N): the determinant of a matrix A whose entries are polynomials using Dodgson's rule, truncated to t^N`):
print(`try: `):
print(` detTPD(GesselMat(5,t,30),t,60); `):

elif nops([args])=1 and op(1,[args])=GesselMat then
print(`GesselMat(k,t,N):  The Gessel k-1 by k-1 matrix truncated to t^(2*N) `):
print(` Try: `):
print(` GesselMat(3,t,10); `):

elif nops([args])=1 and op(1,[args])=GuessPol then
print(`GuessPol(L,n,s0): guesses a polynomial of degree d in n for`):
print(` the list L, such that L[i]=P[i] for i>=s0 for example, try:  `):
print(` GuessPol([(seq(i,i=1..10),n,1); `):

elif nops([args])=1 and op(1,[args])=Hook then
print(`Hook(lambda, c), the Hook of cell c in lambda, Try:`):
print(`Hook([2,2],[1,1]);`):


elif nops([args])=1 and op(1,[args])=Iv then
print(`Iv(v,t,N): the first N terms of the Bessel series I_v(t). Try; Iv(4,t,10); `):

elif nops([args])=1 and op(1,[args])=LeadingIra then
print(`LeadingIra(m,k,r): Inputs symbols m and k, and a non-negative integer, r, outputs, the r+1 leading terms of`):
print(`of the degree -2k polynomial in m enumerating permutations of length m+k that contain at least one increasing`):
print(`subsequence of length m. To reproduce Proposition 9.6 of Nigel Ray and Julian West's   article `):
print(` "Posets of matrices and permutations with forbidden subsequences"`):
print(`Annals of combinatorics 7 (2003), 55-88, type: `):
print(`LeadingIra(m,k,1);`):
print(`To get the first 8 leading terms, type: `):
print(` LeadingIra(m,k,8);`):

elif nops([args])=1 and op(1,[args])=LeadingIraV then
print(`LeadingIraV(m,k,r): Verbose form of LeadingIra(m,k,r) (q.v.). Try:`):
print(`LeadingIraV(m,k,1);`):
print(`To get the first 8 leading terms, type: `):
print(` LeadingIraV(m,k,8);`):

elif nops([args])=1 and op(1,[args])=Mamar then
print(`Mamar(K): inputs a positive integer K and prints an article with K theorems where the r-th theorem`):
print(`is an explicit closed-form expression (of the form (d+r)!-polynomial(d)) for the number of`):
print(` 1...d-avoiding permutations of length d+r (valid for d>=r). It outputs the list of length K whose r-th entry `):
print(` is the expression for the number of 1...d-avoding permutations of length d+r (valid for d>-r). `):
print(` Try: `):
print(` Mamar(6): `):

elif nops([args])=1 and op(1,[args])=MamarSeq then
print(`MamarSeq(K): inputs a positive integer K and outputs the the first 2*d+1 terms of the  enumerating sequences of 1...d-avoiding`):
print(`permutations for d from 1 to K. Try:`):
print(`MamarSeq(10):`):

elif nops([args])=1 and op(1,[args])=Partition then
print(`Partitition(n): the set of integer partitions of n. Try: `):
print(` Partition(7);`):

elif nops([args])=1 and op(1,[args])=RanMatN then
print(`RanMatN(k,N): a random k by k matrix with numerical entries from 1 to N. Try: `):
print(` RanMatN(5,20); `):

elif nops([args])=1 and op(1,[args])=RanMatP then
print(`RanMatP(k,N,t,d): a random k by k matrix with entries that are polynomial in t of degree d, with coefficients from 1 to N. Try: `):
print(` RanMatP(5,20,t,5); `):

elif nops([args])=1 and op(1,[args])=SeqA then
print(`SeqA(k): Inputs a positive integer k, and outputs the list, of length 2*k+1, whose n-th entry is the number of 1...k-avoiding`):
print(`permutations of length n. Try:`):
print(`SeqA(5);`):

elif nops([args])=1 and op(1,[args])=SeqApc then
print(`SeqApc(k): Same as SeqA(k), but much faster for k<=30, since it uses pre-computed expressions for A(d,r) `):
print(`Try:`):
print(`SeqApc(5);`):

elif nops([args])=1 and op(1,[args])=SeqIra then
print(`SeqIra(k,N): Inputs a positive integer k, and outputs the list, of length N, whose n-th entry is the number of 1...k-avoiding`):
print(`permutations of length n. It uses Ira Gessel's amazing determinant formula. `):
print(`Try:`):
print(`SeqIra(3,10);`):

elif nops([args])=1 and op(1,[args])=SeqIraD then
print(`SeqIraD(k,N): same as SeqIra(k,N) (q.v), but using Dodgson's rule for computing determinants, and truncating at each step. `):
print(`Inputs a positive integer k, and outputs the list, of length N, whose n-th entry is the number of 1...k-avoiding`):
print(`permutations of length n. It uses Ira Gessel's amazing determinant formula. `):
print(`Try:`):
print(`SeqIraD(3,10);`):

elif nops([args])=1 and op(1,[args])=Wt1 then
print(`Wt1(d,r,lambda): inputs a symbol d, a positive integer r,and a partition lambda whose sum is <=r `):
print(` and outputs the number of Young tableaux of shape Lambda with an additional first column `):
print(` of length d+r-|lambda| added to it. `):
print(` Try: `):
print(` Wt1(d,4,[1,1]); `):



else
print(`There is no ezra for`,args):
fi:
 
end:



#GuessPol1(L,d,n,s0): guesses a polynomial of degree d in n for
# the list L, such that L[i]=P[i] for i>=s0 for example, try: 
#GuessPol1([(seq(i,i=1..10),1,n,1);
GuessPol1:=proc(L,d,n,s0) local P,i,a,eq,var:
if d>=nops(L)-s0-2 then
 ERROR(`the list is too small`):
fi:

P:=add(a[i]*n^i,i=0..d):
var:={seq(a[i],i=0..d)}:
eq:={seq(subs(n=i,P)-L[i],i=s0..s0+d+3)}:

var:=solve(eq,var):

if var=NULL then
 RETURN(FAIL):
fi:

subs(var,P):

end:



#GuessPol(L,n,s0): guesses a polynomial of degree d in n for
# the list L, such that L[i]=P[i] for i>=s0 for example, try: 
#GuessPol([(seq(i,i=1..10),n,1);
GuessPol:=proc(L,n,s0) local d,gu:

for d from 0 to nops(L)-s0-3 do
 gu:=GuessPol1(L,d,n,s0):
 if gu<>FAIL then
    RETURN(gu):
 fi:
od:

FAIL:

end:

RevMM:=proc(P) local i,N: N:=nops(P): [seq(P[N-i+1]   , i=1..N)]: end:

Partition:=proc(n)
local P,i,N:
with(combinat):
P:=partition(n):
N:=nops(P);
RevMM([seq(RevMM(P[i]),i=1..N)]):
end:

#Hook(lambda, c), the Hook of cell c in lambda, Try:
#Hook([2,2],[1,1]);
Hook := proc(lambda, c)
  local H, i, x, y;
  x := c[1];
  y := c[2];
  H := {};
  for i from y to lambda[x] do
    H := H union {[x,i]};
  od;
  for i from x to nops(lambda) do
    if lambda[i] >= y then
      H := H union {[i,y]};
    fi;
  od;
  H
end:


#Wt1(d,r,lambda): inputs a symbol d, a positive integer r,and a partition lambda whose sum is <=r
#and outputs the number of Young tableaux of shape Lambda with an additional first column
#of length d+r-|lambda| added to it.
#Try:
#Wt1(d,4,[1,1]);
Wt1:=proc(d,r,lambda) local r1,lu,i,j:
lu:=mul(mul(nops(Hook(lambda,[i,j])),j=1..lambda[i]),i=1..nops(lambda)):


r1:=r-convert(lambda,`+`):

if r1<0 then
 RETURN(0):
fi:

lu:=lu*(d+r1-nops(lambda))!:
lu:=lu*mul(d+r1-i+1+lambda[i],i=1..nops(lambda)):
simplify((d+r)!/lu):
end:

#A(d,r): inputs a symbol d and a  positive integer r, and outputs an explicit expression for
#the number of 1...d-CONTAINIG permutations of length d+r. Try:
#A(d,2);
A:=proc(d,r) local gu,mu,mu1,r1:
option remember:
gu:=0:

for r1 from 0 to r do
 mu:=Partition(r-r1):
 gu:=expand(gu+add(Wt1(d,r,mu1)^2,mu1 in mu)):
od:

gu:

end:



#Apc(d,r): pre-computed version of A(d,r) (q.v), very fast for r<=30, for r>30 it just calls A(d,r)
#the number of 1...d-CONTAINIG permutations of length d+r. Try:
#Apc(d,30);
Apc:=proc(d,r):
if r>30 then
 A(d,r):
else
[d^2+1, 1/2*d^4+d^3+1/2*d^2+d+3, 1/6*d^6+d^5+5/3*d^4+2/3*d^3+19/6*d^2+31/3*d+11
, 47+1/24*d^8+1/2*d^7+395/6*d+247/6*d^2+29/24*d^4+9*d^3+25/12*d^6+19/6*d^5, 239
+1/120*d^10+1/6*d^9+31/24*d^8+14/3*d^7+3981/10*d+10459/30*d^2+653/24*d^4+959/6*
d^3+823/120*d^6+67/30*d^5, 1464+1/720*d^12+1/24*d^11+371/720*d^10+239/72*d^9+
2711/240*d^8+661/40*d^7+77993/30*d+118771/45*d^2+222433/360*d^4+308743/180*d^3+
317/80*d^6+10093/120*d^5, 10716+1/5040*d^14+1/120*d^13+3/20*d^12+269/180*d^11+
1583/180*d^10+1322/45*d^9+36689/840*d^8+583/105*d^7+4090943/210*d+1290014/63*d^
2+194675/24*d^4+2824543/180*d^3+37657/144*d^6+857153/360*d^5, 91419+1/40320*d^
16+1/720*d^15+23/672*d^14+349/720*d^13+1377/320*d^12+5821/240*d^11+821551/10080
*d^10+105289/840*d^9-251/8064*d^8+2029061/2520*d^7+71746597/420*d+29601289/168*
d^2+24591023/280*d^4+35480345/252*d^3+6584011/720*d^6+26932307/720*d^5, 882395+
1/362880*d^18+1/5040*d^17+155/24192*d^16+461/3780*d^15+91267/60480*d^14+1357/
108*d^13+12651197/181440*d^12+3621497/15120*d^11+46841863/120960*d^10-1072151/
22680*d^9+291569947/120960*d^8+105703159/3024*d^7+2178173807/1260*d+4419350767/
2520*d^2+680437201/756*d^4+7666760609/5670*d^3+1537061809/9072*d^6+794128583/
1680*d^5, 9403028+737/725760*d^18+3019/120960*d^17+20593/50400*d^16+1409783/
302400*d^15+1/3628800*d^20+1/40320*d^19+13614613/362880*d^14+360479/1728*d^13+
2688254761/3628800*d^12+331208003/259200*d^11-330482557/1209600*d^10+2474198281
/362880*d^9+240752942663/1814400*d^8+114396179747/151200*d^7+4939021051/252*d+
254398763543/12600*d^2+720125046817/75600*d^4+837563855921/56700*d^3+
560960706667/226800*d^6+249334937839/45360*d^5, 108831128+108377/1209600*d^18+
806801/604800*d^17+26293273/1814400*d^16+1861469/16200*d^15+253/1814400*d^20+
779/181440*d^19+2350583801/3628800*d^14+69046757/28800*d^13+2547568523/570240*d
^12-1608761741/1425600*d^11+4154606647/241920*d^10+904808550389/1814400*d^9+
6054415248559/1814400*d^8+5741772052441/453600*d^7+223807632947/924*d+1/
39916800*d^22+1/362880*d^21+36195332307173/138600*d^2+5074682541499/45360*d^4+
505887331841/2700*d^3+460653372623/14175*d^6+14482824698539/226800*d^5, 
1355321582+1/479001600*d^24+1/3628800*d^23+23524111/5443200*d^18+876091/19200*d
^17+15725826509/43545600*d^16+4531192907/2177280*d^15+716297/43545600*d^20+
420029/1360800*d^19+276302745161/34214400*d^14+655375221521/39916800*d^13-\
349761566447/95800320*d^12+382631375209/11975040*d^11+745021360021/403200*d^10+
7539740633171/518400*d^9+69224006357729/1088640*d^8+254838207663589/1360800*d^7
+44414281825979/13860*d+4043/239500800*d^22+989/1555200*d^21+763082835908171/
207900*d^2+11394609198586597/7484400*d^4+6732100102045721/2494800*d^3+
32238640245461/77760*d^6+1086116052927587/1360800*d^5, 18075656078+5/2737152*d^
24+2473/29937600*d^23+6357787153/43545600*d^18+6335530331/5443200*d^17+
471957390479/68428800*d^16+1687210810891/59875200*d^15+45397789/43545600*d^20+
152727007/10886400*d^19+130636436920361/2075673600*d^14-455624375069/62270208*d
^13-3264269839003/479001600*d^12+803604463453873/119750400*d^11+681859598930183
/10886400*d^10+3420475104099791/10886400*d^9+1915790905563049/1814400*d^8+
119235688185053/45360*d^7+1/6227020800*d^26+1/39916800*d^25+1620099480198739/
36036*d+248209/95800320*d^22+216599/3628800*d^21+21146423853594473/386100*d^2+
35707642113020303/1496880*d^4+105902226432426497/2494800*d^3+54934202945854943/
9979200*d^6+170882406043279159/14968800*d^5, 257649950960+13669/38320128*d^24+
4734557/479001600*d^23+408979110863/106444800*d^18+536243581891/22809600*d^17+
1768402104205097/17435658240*d^16+10890608558350793/43589145600*d^15+1/
87178291200*d^28+1/479001600*d^27+1331889883/29030400*d^20+2299961723/4838400*d
^19+1397623576334269/87178291200*d^14-645488927993263/1245404160*d^13+
1260306696344831/53222400*d^12+1932282378803971/7257600*d^11+14563731154868449/
9525600*d^10+5931677863540109/1016064*d^9+2282199489451236263/139708800*d^8+
3481972484432762/93555*d^7+89/498161664*d^26+4573/479001600*d^25+
2729017333548799/4095*d+25620941/121927680*d^22+355075657/101606400*d^21+
3604213438167576677/4204200*d^2+46360030628861659/112112*d^4+
160561014331252206143/227026800*d^3+222329571947073107/2721600*d^6+
711666952803468881/3742200*d^5, 3921673239480+364611589/10059033600*d^24+
305102513/419126400*d^23+1/1307674368000*d^30+1/6227020800*d^29+
3582977772378049/43589145600*d^18+8176023017786347/21794572800*d^17+
667364821795122071/653837184000*d^16+25981631464722737/81729648000*d^15+521/
32691859200*d^28+9277/9340531200*d^27+11317903263971/7185024000*d^20+
4659766300919/359251200*d^19-200240813187205853/52306974720*d^14+
498455089139011687/6227020800*d^13+56089234609599436387/50295168000*d^12+
184349939970908412067/25147584000*d^11+99633914026390263019/3143448000*d^10+
250562198236180274599/2514758400*d^9+1560361378714772082859/6286896000*d^8+
11646573892321600499/20412000*d^7+452119/10378368000*d^26+1710077/1197504000*d^
25+52222474235220826/5005*d+11778992437/1005903360*d^22+17329093129/114307200*d
^21+530336491017024261329/37837800*d^2+25955530482688819479763/3405402000*d^4+
13928288821268483568719/1135134000*d^3+57850687552224453735613/40864824000*d^6+
9121898736266554092523/2554051500*d^5, 63688251561555+402899255147/160944537600
*d^24+792569030999/20118067200*d^23+1139/871782912000*d^30+24559/261534873600*d
^29+3716657037896535599/2615348736000*d^18+348826539587495327/81729648000*d^17+
54934084774314924977/20922789888000*d^16-13930996081707743039/653837184000*d^15
+24981731/5230697472000*d^28+34127117/186810624000*d^27+233871531720778243/
5230697472000*d^20+1398365632747579/4755179520*d^19+1/20922789888000*d^32+1/
87178291200*d^31+36697356910243331293/145297152000*d^14+6003611709473475996049/
1307674368000*d^13+1741988964703906512491/50295168000*d^12+
4253390634859246991447/25147584000*d^11+158805740125262625349/266112000*d^10+
41113982329361481865553/25147584000*d^9+26865935139900910488419/6810804000*d^8+
8341507163823557768203/825552000*d^7+14255346773/2615348736000*d^26+181358999/
1397088000*d^25+6916976963509977633/40040*d+101990182960873/201180672000*d^22+
4452080379199/838252800*d^21+36232472288859114561341/151351200*d^2+
3972325255518601390024019/27243216000*d^4+500019536627008801969063/2270268000*d
^3+577267274538154821152087/20432412000*d^6+105245829677279321953759/1459458000
*d^5, 107374865758411/804722688000*d^24+172700281497119/100590336000*d^23+
165523/348713164800*d^30+507139/24216192000*d^29+196024207238840097737/
10778406912000*d^18+57293182065232609/3267264000*d^17-2172407975853367540591/
20922789888000*d^16+36722186533950689381/52306974720*d^15+291737953/
402361344000*d^28+3769696813/186810624000*d^27+5618172782203405153/
5230697472000*d^20+93360556830019669/16982784000*d^19+691/6974263296000*d^32+
2659/326918592000*d^31+896259021339078997751/48432384000*d^14+
210771332334465494483873/1307674368000*d^13+11160409853551691547457/12573792000
*d^12+44137543330388951601329/12573792000*d^11+6949949859286227006139621/
653837184000*d^10+987064107538928141519689/36324288000*d^9+
412353113429231254490753/5837832000*d^8+519419799000168728787961/2476656000*d^7
+4797520548143/10461394944000*d^26+17641475431/2052864000*d^25+
2061642870195923617329/680680*d+95249358955349789/5230697472000*d^22+
1436895034223959/9144576000*d^21+1/355687428096000*d^34+1/1307674368000*d^33+
11017439790599089610158189/2572970400*d^2+78054800617352470380555623/
27243216000*d^4+1031343649432371717524171/252252000*d^3+
50470719799307440081148813/81729648000*d^6+1472579323752070337017271/972972000*
d^5+1101916619437395, 18483922462764761/3138418483200*d^24+36868881341930783/
581188608000*d^23+1625903189/18830510899200*d^30+3957471667/1426553856000*d^29+
226402789143888704092891/2134124568576000*d^18-163886976971238901420399/
355687428096000*d^17+89436375915987389319817/62768369664000*d^16+
569736258011091573735679/7846046208000*d^15+4599225375601/62768369664000*d^28+
1967062993559/1222760448000*d^27+46226938868141047573883/2134124568576000*d^20+
83965714478424956690483/1067062284288000*d^19+2706559/62768369664000*d^32+
6818947/3138418483200*d^31+1/6402373705728000*d^36+1/20922789888000*d^35+
965218389039624972607781/1307674368000*d^14+2567859391755177514854311/
560431872000*d^13+238683890886485671922554577/11769069312000*d^12+
66788967454089479784903079/980755776000*d^11+9391057212928260610003909/
50295168000*d^10+1446099279546686467978379707/2942267328000*d^9+
2322694978681593468676627/1556755200*d^8+5993332633179830224987301/1225944720*d
^7+88340170741337/2988969984000*d^26+4762317100003/10450944000*d^25+
344732560060700157075869/6126120*d+320776853267942137/570621542400*d^22+
1608239896860315419/402361344000*d^21+2983/426824913715200*d^34+40787/
62768369664000*d^33+56464320324099549523906571/701719200*d^2+
80177235304933608415262020061/1389404016000*d^4+759497028605975368874810669/
9648639000*d^3+20795316827958048880485953849/1471133664000*d^6+
2654765524742065576482254707/81729648000*d^5+20261782443671580, 1/
121645100408832000*d^38+1/355687428096000*d^37+93883242999173207/418455797760*d
^24+5347172847509408609/2615348736000*d^23+1950109085423/188305108992000*d^30+
707256961571/2690072985600*d^29-159384987734740144829149/85364982743040*d^18-\
407540278392993964078841/1067062284288000*d^17+690232485756067147561513/
2510734786560*d^16+531818752132581198151103/160123392000*d^15+176646251711213/
31384184832000*d^28+4805461399065149/47076277248000*d^27+
2329605676904182798446181/6758061133824000*d^20+6144078364887257192281579/
10137091700736000*d^19+1750512431/188305108992000*d^32+95628647/280215936000*d^
31+59/128047474114560*d^36+3671/76218734592000*d^35+2444976311393244269054867/
105080976000*d^14+2389056649595569366960333/20756736000*d^13+
5051888882558373263584967741/11769069312000*d^12+3756102553001552250216497599/
2942267328000*d^11+449527664918451603914003089/130767436800*d^10+
6105260130599059272539619779/588453465600*d^9+836599501288661351700010583/
22986463500*d^8+5939441592455033794944491153/49037788800*d^7+14083439096431417/
8966909952000*d^26+23785239222681997/1162377216000*d^25+
25775670157752732722537419/23279256*d+6456772972252949622041/426824913715200*d^
22+13222388466812436675809/152437469184000*d^21+2564813/711374856192000*d^34+
12912331/62768369664000*d^33+233628370668645684697900446931/146659312800*d^2+
1659194455335693700887388361573/1389404016000*d^4+7615366234303854968484742159/
4824319500*d^3+8267499647400897240280207411453/25009272288000*d^6+
985556936665776536139813346691/1389404016000*d^5+394637177292096000, 
8109943520909142810+991/34755742973952000*d^38+21313/6402373705728000*d^37+
64446663415002620121329/8536498274304000*d^24+3759525904740815558467/
64670441472000*d^23+135728539921829/144850083840000*d^30+3709856497140709/
188305108992000*d^29-58741040837092750354187633/2134124568576000*d^18+
20102499406992868504951267/20324995891200*d^17+13794563159464010801561069531/
941525544960000*d^16+13675599176147317696566422999/117690693120000*d^15+
1335435387771354319/3766102179840000*d^28+142954070744513543/26153487360000*d^
27+541170784732421743007401763/162193467211776000*d^20-\
4120711448097177146744879/614369193984000*d^19+4932752329943/3766102179840000*d
^32+3978737471971/104613949440000*d^31+361057/1293408829440000*d^36+95504897/
5335311421440000*d^35+6042022373320360093980488321/9415255449600*d^14+
12517307966723551735075474453/4707627724800*d^13+1/2432902008176640000*d^40+1/
6402373705728000*d^39+509093874074287960026837381257/58845346560000*d^12+
1426438216175762368941735729241/58845346560000*d^11+
25155322926862117552928957623/350269920000*d^10+761846334446908609849432429411/
2942267328000*d^9+483024371222126013326975264340163/500185445760000*d^8+
34979497313276242288294558825873/11367851040000*d^7+6582584123549509/
91445760000*d^26+2551438937034661481/3170119680000*d^25+
2680165879438882382354437019/116396280*d+28572562185102765777389579/
81096733605888000*d^22+4758262357890769242390473/3119105138688000*d^21+
834527641/914624815104000*d^34+1298805551/34237292544000*d^33+
1626697314836810739408089646031/48886437600*d^2+
1122380754835571321340926703472831/43997793840000*d^4+
48576150079954611296030701156691/1466593128000*d^3+
23295603684690217665024797238697/2977294320000*d^6+
219240643566863801277074148271753/13894040160000*d^5, 1/51090942171709440000*d^
42+1/121645100408832000*d^41+175139679629113410810+146837101/
7298706024529920000*d^38+138321791/96035605585920000*d^37+
154303574563044885687646493/681212562289459200*d^24+154254568643496678364547119
/106439462857728000*d^23+38235183893377351/553063956480000*d^30+
24519195823296686003/19772036444160000*d^29+2208116816083466146925222669309/
672249239101440000*d^18+14150644240907660273502912092771/224083079700480000*d^
17+11277148956703942856442322327451/19772036444160000*d^16+
482667222231803172992031127663/137305808640000*d^15+303864544250016467771/
15817629155328000*d^28+255338049389415023/996323328000*d^27-\
1331172108259424603888530081/69511485947904000*d^20-\
26389474553314068604389024649/121645100408832000*d^19+1561458510235991/
11298306539520000*d^32+47492269901399/14265538560000*d^31+221098657223/
2688996956405760000*d^36+286977480373/74694359900160000*d^35+
11421199677176510964237625764539/706144158720000*d^14+
20441625697850542927812154927981/353072079360000*d^13+1103/663518729502720000*d
^40+19661/91233825306624000*d^39+212406667963333646564699267268131/
1235752277760000*d^12+620428707255788291408172552082861/1235752277760000*d^11+
2089795525615566762196176219827423/1167099373440000*d^10+
38076457914034316329484761936315361/5251947180480000*d^9+
39814391094383610823147761232654117/1500556337280000*d^8+
2959706359785393679302726112392707/37513908432000*d^7+34061149840545326580889/
11640679464960000*d^26+129279649446558052416239/4573124075520000*d^25+
58721035436910581441654518619/116396280*d+23188143861161149412249370769/
3406062811447296000*d^22+15241706255085786189720914101/851515702861824000*d^21+
28746416438143/192071211171840000*d^34+27821864599289/5649153269760000*d^33+
107527469568630837057849967002893/146659312800*d^2+
522671770611980742633893030018759651/923953670640000*d^4+
22477605082787467211360311957162111/30798455688000*d^3+
311429087497131509375342034034891363/1663116607152000*d^6+
1990862520336518985145064746683445907/5543722023840000*d^5, 851/
9289262213038080000*d^42+95743/7298706024529920000*d^41+17933420509/
2620048316497920000*d^38+960050574227/2688996956405760000*d^37+
451688026667636856697229831483/74933381851840512000*d^24+
382084839474612819787538053049/12488896975306752000*d^23+230347747042433551771/
52725430517760000*d^30+215695173068365025639/3163525831065600*d^29+
273655920337787976808192932149/1034229598617600*d^18+
12570455390490250626966824258509/4573124075520000*d^17+
14386524162521956279083533796791/760462940160000*d^16+
119345742637366490845438751445041/1235752277760000*d^15+
992761440535441676586661/1075598782562304000*d^28+1379310084495388547525099/
128047474114560000*d^27-5951260257525442932618772938143/4644631106519040000*d^
20+80087875144252753753515726926603/8515157028618240000*d^19+
1869908997196399433/158176291553280000*d^32+19262259645141704717/
79088145776640000*d^31+20944219753469/1344498478202880000*d^36+387416933679187/
672249239101440000*d^35+20741994280692292050599126985558671/54373100221440000*d
^14+5521634430453578223130740534476983/4531091685120000*d^13+
3959567879158149119040+1041631/768284844687360000*d^40+262099703/
2432902008176640000*d^39+412804755478226801273709704078795623/
115542837970560000*d^12+257567751240697703386252167512700967/21007788721920000*
d^11+1089333008319426299958175789054379927/21007788721920000*d^10+
749236582957044154909765159190107823/3501298120320000*d^9+1/
1124000727777607680000*d^44+1/2432902008176640000*d^43+
146917190162745881926645931922539724181/199573992858240000*d^8+
8115894160003907563129378053503741293/3991479857164800*d^7+
3652279902067890782740144439/34060628114472960000*d^26+
563722853763198439386046669/630752372490240000*d^25+
168775799168499366039171900952/14549535*d+2353689832350825423554883979529/
24977793950613504000*d^22-318368602704919238965977709/15138056939765760*d^21+
77151816993634139/4225566645780480000*d^34+12402680945655697/24856274386944000*
d^33+721993080074008282658905537698041/42454011600*d^2+
66534898721956313916409506043069328639/5081745188520000*d^4+
67440207253754350256191632597657941/3985682500800*d^3+
75614031698939737866003035688222963031/16631166071520000*d^6+
6661679468753817228880338220192410341/791960289120000*d^5, 547837/
6386367771463680000*d^42+13731587/1824676506132480000*d^41+
93404729170305578435160+151966506205013/102181884343418880000*d^38+
18353243041291/298777439600640000*d^37+39724234193363273541797077439671/
287244630432055296000*d^24+3512031704921693215625173004011/7181115760801382400*
d^23+1314046084309195393668053/5377993912811520000*d^30+
1807444119224010502835741/537799391281152000*d^29+
2182532184474563460964966236395069/168062309775360000*d^18+
67227875042063487448736189395946087/672249239101440000*d^17+
12309986051282051755451936435983103/21749240088576000*d^16+
67143044795481597426671075039806873/27186550110720000*d^15+
170827419721761444505278227/4257578514309120000*d^28+
1168269549137983852374569837/2838385676206080000*d^27+
925107936842459892579837066934943/51090942171709440000*d^20+
27316128581756936970740881820913833/25545471085854720000*d^19+
68195545719231906149/79088145776640000*d^32+10952038895092731547/
706144158720000*d^31+21500388018352693/9859655506821120000*d^36+
110174448393748979/1643275917803520000*d^35+
1586840805229527352423822955686144151/184868540752896000*d^14+
221493610655197342277360086718402579/8558728738560000*d^13+52700251/
99592479866880000*d^40+195604117301/6386367771463680000*d^39+
19567235127201481492853362373396465431/231085675941120000*d^12+
115725525690213201135058733879431309/323196749568000*d^11+
649513794463855478213886652511042000593/399147985716480000*d^10+
1279422081438104287033690334060296746233/199573992858240000*d^9+269/
56200036388880384000*d^44+1013/1344498478202880000*d^43+1/
25852016738884976640000*d^46+1/51090942171709440000*d^45+
4080345115593901503485847655975410566897/199573992858240000*d^8+
585050566483940672660585972066439025361/11087444047680000*d^7+
9826027180633885338126920213/2754903744552960000*d^26+
1185897340900777082522916170249/46833363657400320000*d^25+
26657762502558239865651736453669/95611230*d+304015448076447600137118007920973/
1124000727777607680000*d^22-2820238957753002223528186385867/429335648501760000*
d^21+885080110767912659/492982775341056000*d^34+18283579091937789821/
434984801771520000*d^33+7678488369473354348884741631576043847/18552403069200*d^
2+1614053318883953603329721481288792364643/5081745188520000*d^4+
46601665254628848165801198133886389987/112927670856000*d^3+
20603613680360955382780241584510202237651/182942826786720000*d^6+
460983639067746107002163923023231697867/2258553417120000*d^5, 23401899221/
613091306060513280000*d^42+5932757573/2432902008176640000*d^41+
400080188416031813/1686001091666411520000*d^38+1446240020024296657/
177473799122780160000*d^37+1557578761498604577700598600820509129/
620448401733239439360000*d^24+3181386284628320637930262572596609/
994308336110960640000*d^23+7581584878685297929306413239/613091306060513280000*d
^30+46319484072453571117820729071/306545653030256640000*d^29+
15352342305645488465827184073112545479/29578966520463360000*d^18+
16048780166112781828774886471762128949/4929827753410560000*d^17+
3867802307701914816008515832960604733/246491387670528000*d^16+
331345902231584247747162093415973354933/5546056222586880000*d^15+
2393921494012322734713532808027/1498667637036810240000*d^28+
3233276904203989677326605075387/224800145555521536000*d^27+1/
620448401733239439360000*d^48+1/1124000727777607680000*d^47+
210146204491867463231402444881531843/51090942171709440000*d^20+
4598534961675805628993747958625482151/76636413257564160000*d^19+
18603839641600532057033/335251568590848000*d^32+1296424700933315599848481/
1466725612584960000*d^31+86850276819160799891/354947598245560320000*d^36+
181237007143885579/28090186629120000*d^35+
131469170325499712864796581371407014807/693257027823360000*d^14+
221873597590510463205777973828373021/370725683328000*d^13+107107653689249/
817455074747351040000*d^40+45155722751/7519271316480000*d^39+
255726571062323200473690102819592963221161/105375068229150720000*d^12+
2560764073269927614561153287197825209771/217717083118080000*d^11+
2292829333062871589473950+5023740160808305576432521894538157288183/
95795516571955200*d^10+229811371908519323248995073728345054257033/
1197443957149440000*d^9+22992817/4496002911110430720000*d^44+50372681/
102181884343418880000*d^43+59/248179360693295775744*d^46+138119/
3372002183332823040000*d^45+3742110753868850193752896330343558411403203/
6585941764321920000*d^8+760433702706756755324133460845396278720381/
548828480360160000*d^7+792653160769063895133162885060217/7386290496824279040000
*d^26+624676437060540605263637816050441/994308336110960640000*d^25+
415222430662120097134815689811691/59491432*d-\
102118790522409649849072196039386031/3372002183332823040000*d^22-\
97484166610258848960566275826737/3981112377016320000*d^21+
26593099351058662912891/177473799122780160000*d^34+2003014592030528722873/
652477202657280000*d^33+1328393765473714854173637165699001841/126206823600*d^2+
540495113616434706996737875398373669670011/66788651049120000*d^4+
164617080888606104334177774982249716912733/15584018578128000*d^3+
83888237243916200467778281840528397602229/29270852285875200*d^6+
629556605673585277212196684034476628277193/121961884524480000*d^5, 
58444937722576468999762974+987303916111/92194181362483200000*d^42+
14826293013347/27370147591987200000*d^41+1/15511210043330985984000000*d^50+1/
25852016738884976640000*d^49+1017954889886298348533/33720021833328230400000*d^
38+789550537396080916763/887368995613900800000*d^37+
5158128747268507895935859297576014771/206816133911079813120000*d^24-\
9678261561616761384141982168822849829/77556050216654929920000*d^23+
14912572351958529961943640306761/25938478333329408000000*d^30+
4061034930010337495091921951617/648461958333235200000*d^29+
2717663104216052141617644098427564935339/147894832602316800000*d^18+
21691116704561958979675457132872020295097/221842248903475200000*d^17+
22699499650668957867811353497519630466889/55460562225868800000*d^16+
757612791909221736200686553830970931403/543731002214400000*d^15+
30273494120710367175449841475210177/517040334777699532800000*d^28+
2821646157827255322945427948174111/6155242080686899200000*d^27+179/
15908933377775370240000*d^48+40981/19389012554163732480000*d^47+
126548494237178304846431154511228200253/468333636574003200000*d^20+
44557593277529749932057006087673010029/16860010916664115200*d^19+
3596907725443217995399341313/1114711465564569600000*d^32+
11739541140505253689750188883/255454710858547200000*d^31+
41167028933380821770357/1774737991227801600000*d^36+237852866982038930937857/
443684497806950400000*d^35+85004871154206655014612862781640095831743/
19513901523916800000*d^14+723008098373338514729288680685965831746851/
43906278428812800000*d^13+456409421782069963/19268583904758988800000*d^40+
434911370047312607/481714597618974720000*d^39+
1302596746887851488809433460312011961034409/15965919428659200000*d^12+
4851509225240723126156084965047934409929579/11974439571494400000*d^11+
371323636549035277446666295917608003704397591/219531392144064000000*d^10+
75356659818160959502550442648565473504869719/13171883528643840000*d^9+243323911
/94321739393925120000*d^44+18498455071/102181884343418880000*d^43+26295847/
91242412019594035200000*d^46+4003469/131718835286438400000*d^45+
130553018961029648567568083776076324884191439/8232427205402400000*d^8+
29051509791474150080455533761815448524494731/784040686228800000*d^7+
8891937922399867116172969541941270681/3102242008666197196800000*d^26+
375267572581692196561234945814557201/29377291748732928000000*d^25+
269806234669191256991355823801407411/1487285800*d-\
852209046954633792156214422021143921/1532728265151283200000*d^22+
22520791245428991793935029197322946751/1532728265151283200000*d^21+
26018039400037604527278677/2366317321637068800000*d^34+
5380867019956790612502751/26889969564057600000*d^33+
2847613319370379397185613476823235157/10221709680*d^2+
101206269869713424418616265094404039645802973/467520557343840000*d^4+
4406337121203539516173045798737630167485069/15584018578128000*d^3+
907231200002598194114385768067362869319338717/12021957188841600000*d^6+
871394876357791781486513798172573874583363593/6375280327416000000*d^5, 
1544629616249609314460269224+1/403291461126605635584000000*d^52+1/
620448401733239439360000*d^51+65390720437649297/29973352740736204800000*d^42+
12379465419638656541/134880087333312921600000*d^41+1753/
3446935565184663552000000*d^50+9199/88635485961891348480000*d^49+
11465027735100813878233/3549475982455603200000*d^38+49415284227395559837703/
591579330409267200000*d^37-1346903154689558418481978656791514411889/
3102242008666197196800000*d^24-1104275986359050998156952516608444196303/
258520167388849766400000*d^23+7845825855672178468849909159811087/
316555307006754816000000*d^30+17759192315989561025490240133155901/
73862904968242790400000*d^29+265052887790255705508045771948205554632069/
443684497806950400000*d^18+610688345343878647390041923099969095382581/
221842248903475200000*d^17+4224629504968156541589839935674921330698743/
415113905145139200000*d^16+37141227758813584726707344914085221573756777/
1141563239149132800000*d^15+159072569387893394033658499907444122693/
80658292225321127116800000*d^28+2646708014996732339088836707147575391949/
201645730563302817792000000*d^27+612361/39772333444438425600000*d^48+914920373/
517040334777699532800000*d^47+20210505569533266951714696494195739826529/
1532728265151283200000*d^20+22578235972194598676922125756660752244887/
221842248903475200000*d^19+764898281881610738208025580563/
4436844978069504000000*d^32+9930177845511836421607587277099/
4496002911110430720000*d^31+3906646225054608155055109/2028271989974630400000*d^
36+2404425261128016876611443/60674803118899200000*d^35+
521387738202503367334507285432749612357538511/4566252956596531200000*d^14+
15256173923741241776769846214044179570095237/27730281112934400000*d^13+
1985472358450736552003/584480378444355993600000*d^40+12184105717247223238813/
109590070958316748800000*d^39+7828699767610224832112902901011893641356956277/
2634376705728768000000*d^12+1851460895455436485235667181757536749454425689/
131718835286438400000*d^11+11887002231060212234896111865689398934554859081/
219531392144064000000*d^10+659244896747512527614557353120593770653650647/
3874083390777600000*d^9+220063439125601/269760174666625843200000*d^44+
42746694196427/943217393939251200000*d^43+8923428179/54425298397652582400000*d^
46+121237155289/9634291952379494400000*d^45+
2480627336190463508424870298895983900570169851/5548595625619200000*d^8+
641797459024170971273970285080184388782730864487/631152752414184000000*d^7+
3971091062753032544597174817797261531/61524250362563788800000*d^26+
2598052080679552993058707582180336470553/15511210043330985984000000*d^25+
47787566932294554586544230159951418/9784775*d+
59848729057461754149146947761540000119/1296923916666470400000*d^22+
19888140103862088096089943844175449208951/16860010916664115200000*d^21+
571932088638635380758160843/786472812439142400000*d^34+
320577769511381197482372001217/26976017466662584320000*d^33+
245882326208353329061349863963607418536657/32157498653280*d^2+
12283573154432603728381864523858254273022307733/2025922415156640000*d^4+
1596472975118502056126073215015999635131222577/202592241515664000*d^3+
58059585055321776931003327803435493836027532123/28051233440630400000*d^6+
266289074513582571120864304151891122908507633023/70128083601576000000*d^5, 
42279453086213397896473041296+1901/86419598812844064768000000*d^52+113089/
23266815064996478976000000*d^51+11074769888163864430241/
31561940435995223654400000*d^42+673700160568569842749/53134579858577817600000*d
^41+72762113/93067260259985915904000000*d^50+908048461/
9306726025998591590400000*d^49+1/10888869450418352160768000000*d^54+1/
15511210043330985984000000*d^53+244052237524706217092754253/
809280523999877529600000*d^38+11390475414945211412902469/1638219684210278400000
*d^37-714388323388719581365720125334784421455153/27920178077995774771200000*d^
24+7118273253191803438810078298416008819971/66476614471418511360000*d^23+
190115708690714579047135615049290088479/191032797375760564224000000*d^30+
1721912000930223262618925528791314816367/201645730563302817792000000*d^29+
53708180477018893600275538417824665483481157649/2958931915874552217600000*d^18+
12065946837893954861989304264929694707524555953/164385106437475123200000*d^17+
2535609270414784391212880867432426525398001419/10274069152342195200000*d^16+
219202658889809491597612485562836232318946011/266858939021875200000*d^15+
36478144833769993124774371751145330386977/604937191689908453376000000*d^28+
882741852130439680187879061047626788149077/2722217362604588040192000000*d^27+
274508241253/27920178077995774771200000*d^48+478168561411/
581670376624911974400000*d^47+3995373320413722293996722189598000034782603/
7225718964284620800000*d^20+9049875795869886545950247844333151372063067/
2529001637499617280000*d^19+6324106085070422048354470057627199/
738629049682427904000000*d^32+575567238401678911316406635279374493/
5816703766249119744000000*d^31+523468704806326951462429770767/
3641762357999448883200000*d^36+28356676423128382501860530231/
10648427947366809600000*d^35+107795422883862907821506938411817745168281687849/
29354483292406272000000*d^14+164584039568353456079763336455307216367173026141/
7903130117186304000000*d^13+2145901048765504856068909/5260323405999203942400000
*d^40+46250921821573651773311993/3945242554499402956800000*d^39+
2620391638763082424838696515320921590681710657189/23709390351558912000000*d^12+
11794263771383997849427752264589797699082886999/24392376904896000000*d^11+
78177748472617607913641576181120556031852995096541/45442998173821248000000*d^10
+3025375354084936414134360082879463605589440233893/596190938140512000000*d^9+
75409268644665469/404640261999938764800000*d^44+1742113973251968773/
202320130999969382400000*d^43+21226511847839/364969648078376140800000*d^46+
612689880102173/173417255142830899200000*d^45+
5111385920156933865404442534134667360928226213581/398622790998432000000*d^8+
54648801964200377699593445131996601490836664733333/1893458257242552000000*d^7+
1258771761627007782257376198785347014897499/1209874383379816906752000000*d^26-\
904193157024073805557920672006878832103/912424120195940352000000*d^25+
1364854899630001673628720026851856227579/10039179150*d+
223559999441737528657283745266538424033/45160743526778880000*d^22+
9764380567134979710215906203773422366685247/151740098249977036800000*d^21+
10506014058912883157546332040389/238023683529375744000000*d^34+
3960572762684581309330613140025719/6069603929999081472000000*d^33+
104666786762909153829865802102643142806210899/482362479799200*d^2+
32614728981292098510457448555012074095343273183/184174765014240000*d^4+
415199258039339989646647233723116240266748844089/1823330173640976000*d^3+
36107698220417348814379420937358615425705814321961/607776724546992000000*d^6+
302460875790522169073479592999223283618952431998041/2734995260461464000000*d^5,
20338777/537721948168807514112000000*d^52+118862123/23266815064996478976000000*
d^51+10396961639605925441370281/220933583051966565580800000*d^42+
4286144385114099123557519/2869267312363202150400000*d^41+
1197653038548942886185718322684+1/304888344611713860501504000000*d^56+1/
403291461126605635584000000*d^55+272611101769/488603116364926058496000000*d^50+
6597735822919/130294164363980282265600000*d^49+3973/
4355547780167340864307200000*d^54+263227/1209874383379816906752000000*d^53+
367467278392001806489307189729/14567049431997795532800000*d^38+
28311014291527511471537659681/53952034933325168640000*d^37-\
2604385747087205794887459637564744442033/499849735411689062400000*d^24+
87445139528188847485836921002667905016555641/4441846512408418713600000*d^23+
1889780990412872457909849634762130499828761/50814724101952310083584000000*d^30+
4235297151462349394066466406697611242810767/15244417230585693025075200000*d^29+
5389458921325638890591461362650522870067391550629/10356261705560932761600000*d^
18+37917643864136107991172582598634273564104334869/20187644650216243200000*d^17
+35401887079886922382705324238631102004595736210913/5753478725311629312000000*d
^16+242932859165005523727273196641619399797168332231/9784827764135424000000*d^
15+6103292883032401775603454487653397482839477/3764053637181652598784000000*d^
28+1764481812108913761117756200300740046606333/286549196063640846336000000*d^27
+869995298214101/223361424623966198169600000*d^48+21639077124499/
83970460384949698560000*d^47+1027812243773671393921055124649549870021258591/
48907965551645491200000*d^20+1713305968313963061168157611973344003981101809/
14612009461108899840000*d^19+16857788192080697228438025449473221769/
42327966765474643968000000*d^32+5020409141963659552123165918723232321327/
1209874383379816906752000000*d^31+10018027242533071634528580649633967/
1019693460239845687296000000*d^36+7254162911135714699936782667141/
43891763956604928000000*d^35+30355495719106641976689287703990149236700604817849
/215755452199186099200000*d^14+
1002931717489595301915659871862947446231626659091/1215866171874816000000*d^13+
10861392433643216597051987/255045983321173524480000*d^40+
34472698128257717379619350109/31561940435995223654400000*d^39+
15592653699542962954888751623883921554787316845047727/3817211846600984832000000
*d^12+94129971899496822769154281711267306397858667174350693/
5725817769901477248000000*d^11+
34635895608302503043111157436829987660049007577500519/636201974433497472000000*
d^10+12489268803380062292027662828840709075251554712882829/
81797396712878246400000*d^9+4224217720936076071673/126247761743980894617600000*
d^44+90726676462698181349/68315888389600051200000*d^43+22086504797645867/
1489076164159774654464000*d^46+1819209457392938587/2427841571999632588800000*d^
45+129989594024236484550114370402402868480034637259696093/
344609402818144464000000*d^8+
588037712048517184747980308949085271814465352963793611/689218805636288928000000
*d^7+975452604598625838997908181609003709580067/518517592877064388608000000*d^
26-540966048619225495501289783956262464179739/4046402619999387648000000*d^25+
78478332504693399962683982163112676268971/20078358300*d+
144609252739335635465904383563858363393506223/472080305666595225600000*d^22+
893723718044963951507980837666500822518898413/303480196499954073600000*d^21+
1783163989942114703873798269696543/715902001999891660800000*d^34+
9345649579781057124500002133184976861/279201780779957747712000000*d^33+
3064502058276947392516533160061240487253131383/482362479799200*d^2+
38065109584928969053248479895536495913794051640493/7090728453048240000*d^4+
1126825639228391597495019865772424974807176830703/165757288512816000*d^3+
26597277276625087670372626590575156803393360148539/14875654097304000000*d^6+
32219128020722771771573039693344141734533284637120647/9572483411615124000000*d^
5, 1/8841761993739701954543616000000*d^58+1/10888869450418352160768000000*d^57+
35090540904392649947132912741180+3053331299489/101629448203904620167168000000*d
^52+104826210241/35534772099267349708800000*d^51+4830673478776117698751246723/
883734332207866262323200000*d^42+244554268279677916169352319/
1578097021799761182720000*d^41+443/12195533784468554420060160000*d^56+25387/
2722217362604588040192000000*d^55+83564575622821/339897820079948562432000000*d^
50+8711633379017/493538501378713190400000*d^49+25366741/
14518492600557802881024000000*d^54+308060017/1209874383379816906752000000*d^53+
1965924920206180340079993758974993/1019693460239845687296000000*d^38+
9307005807628845968733271896779819/254923365059961421824000000*d^37+
217070790690279280415643576862492552518405683/3006788408399544975360000*d^24+
34607508986131995075387571021407961334901404593/24430155818246302924800000*d^23
+11346766874421550470751098741163159158324046787/
8841761993739701954543616000000*d^30+
776159857038336822297854364904743208767506981/96106108627605456027648000000*d^
29+122485006856247777987903250616892877507431359581993/
8630218087967443968000000*d^18+
273795193995704582006087233119272334319656724173589/5753478725311629312000000*d
^17+601001942753241523714300910587311722704386307452587/
3452087235186977587200000*d^16+
71614474705096785496424887335430221633205987997629/77055518642566464000000*d^15
+10751036528866163509374464144689306143273666517/304888344611713860501504000000
*d^28+13221716379717782785377386959592914447412693/279201780779957747712000000*
d^27+246670410777646283/223361424623966198169600000*d^48+10535916973907209/
173417255142830899200000*d^47+
30732333255778788479004106819850358201339625377887/41425046822243731046400000*d
^20+29969775003119228932835063156187178328766200706863/
8285009364448746209280000*d^19+354048718514549531113100867365270411062211/
20325889640780924033433600000*d^32+73004382734484244081007619838007287173733/
448365212664285088972800000*d^31+975152493889921235767496488568885443/
1563529972367763387187200000*d^36+18731482002246048193170970693102050017/
1954412465459704233984000000*d^35+
1653817307186972810878208439408693470314390690906649/281953147760300016000000*d
^14+57636552895295516692015607023661341851587306915304247/
1761790083046608384000000*d^13+1503797602419339895672228651277/
378743285231942683852800000*d^40+544455888054398304403289157043/
5917863831749104435200000*d^39+
1704287072932783348784225241027793978759629277597136647/
11451635539802954496000000*d^12+
633995811260626545153400267079623210691200357509165299/
1145163553980295449600000*d^11+
3669428141572433010633767297066618790466085266178010661/
2126732314534834406400000*d^10+
57949398495009574592200626095733728002782338454393482287/
12405938501453200704000000*d^9+4409023232913416739663319/
883734332207866262323200000*d^44+5492152052419101254364013/
31561940435995223654400000*d^43+505604980272592376453/
170805795300680033894400000*d^46+368605205906181107821/
2869267312363202150400000*d^45+
988726971532005543095535544069543185350866890563547997/86152350704536116000000*
d^8+6064009287140159350563757986864100950744775870970862541/
229739601878762976000000*d^7-3170640202858768680401516282823287694234045929/
5081472410195231008358400000*d^26-135011853505010146189842887164985263028564273
/59224620165445582848000000*d^25+1731466097422151624861103185486918223510937/
14930061300*d+2545255068801067872703286371507379612111896370729/
165700187288974924185600000*d^22+
84234613058114571794911215736451796776558703829/696219274323424051200000*d^21+
638352740313188514202596680137408396361/4839497533519267627008000000*d^34+
1465574316131289235421437621615014606049/907405787534862680064000000*d^33+
107224935540820879772369317815592287352858995571/559540476567072*d^2+
825561619620718632753970731584167255090269431679169/4908965852110320000*d^4+
127069237629213397438604171335646885407577045480567/607776724546992000*d^3+
43153252353024532630028592824155245294724122947859167/765798672929209920000*d^6
+340006117894898671771034275169862624374340559500180173/3190827803871708000000*
d^5, 1062943510029508165549853532894752+73811/53050571962438211727261696000000*
d^58+18461/48140264938691662184448000000*d^57+44726163308057573/
3048883446117138605015040000000*d^52+133583128073101571/
117264747927582254039040000000*d^51+1/265252859812191058636308480000000*d^60+1/
304888344611713860501504000000*d^59+8991797178791945346729138496591/
15907217979741592721817600000*d^42+9148063615733412044421557049409/
631238808719904473088000000*d^41+706252847/9146650338351415815045120000000*d^56
+7909929593/653332167025101129646080000000*d^55+3621273741556680133/
46905899171032901615616000000*d^50+1441013623483727519/
312705994473552677437440000*d^49+72182668853/46905899171032901615616000000*d^54
+5521060404371/33876482734634873389056000000*d^53+
19225858258142474267373690281402555629/140717697513098704846848000000*d^38+
166831011163818046134927345638341980871/70358848756549352423424000000*d^37+
103290846254175332816743456962438941700480449958577/
16333304175627528241152000000*d^24+
3274000248434534399758735149362635239978789227407/41788424425947623424000000*d^
23+10634604075902271532477158273666364395051090913069/
265252859812191058636308480000000*d^30+
5229524179756047114841754390274984709901592544111/
26525285981219105863630848000000*d^29+
227985320402353310986650465953373854779012042386533/609191865032996044800000*d^
18+22187547689115203175430689177160387691808215100690509/
17260436175934887936000000*d^17+
3320040072415017948484450601310092404130815349649103337/
541350043699776030720000000*d^16+
71388638428585750766085408425260879135983142521848601959/
1786455144209260901376000000*d^15+
36712399284990956535791611632543385362822455423/83151366712285598318592000000*d
^28-647599052723163220630891716725306167654173286543/
254073620509761550417920000000*d^27+138940557152278343123/
569352651002266779648000000*d^48+38639951723357006024507/
3350421369359492972544000000*d^47+
76483942063375856194142190307069866492248897314976051/
3106878511668279828480000000*d^20+
721689247907305991424041400958446300426849297927767/6828304421248966656000000*d
^19+7037246698908583945845223869082963876150333319/
9824179993044113282826240000000*d^32+
157597894836336733154315337764927518289571272701/
26525285981219105863630848000000*d^31+12588313261525792108390904610986705530463
/338764827346348733890560000000*d^36+798329729833732601916571024240730071043413
/1524441723058569302507520000000*d^35+
74083845343622556603023112241125020882654755728548727793/
297742524034876816896000000*d^14+
17567069926201419726030481489149335235006293007035720069/
13741962647763545395200000*d^13+134154777944429407989463866519942619/
397680449493539818045440000000*d^40+56697092742815318145033326006988683/
7953608989870796360908800000*d^39+
11937732692180578575117382005616880907369051129430743324079/
2233068930261576126720000000*d^12+
2958824568478905196570936893498994980257940257114048213213/
159504923590112580480000000*d^11+
8794447963128464131580048314256478252599626475852706775771/
159504923590112580480000000*d^10+
2727211228697719134985459602305058201543206965944898184683/
18608907752179801056000000*d^9+17020799215919841653350627789/
26512029966235987869696000000*d^44+265230723542464306455640658243/
13256014983117993934848000000*d^43+59602738385499822802886249/
121955337844685544200601600000*d^46+27457665379782672841241581/
1472890553679777103872000000*d^45+
826557587023919449078232769192974835150242902136250301/2272149908691062400000*d
^8+2949686613650699515195985588923782048196728156481866687841/
3446094028181444640000000*d^7-1918122224065943531011731607263402809365729415861
/95277607691160581406720000000*d^26+
20108153669172088930320555549547329491747171/87740178022882344960000*d^25+
516743893406942268799956782920894415255090564/145568097675*d+
1696817731833884640093181382238380251187089848995563/
2485502809334623862784000000*d^22+
5902475214062949474891152653684290106552548225913/1283834095730694144000000*d^
21+446913718487791681617777639614155608105187/67752965469269746778112000000*d^
34+3541919367945118819856400556269744657026867/48140264938691662184448000000*d^
33+14862055832088499707219419890391115019089878246701/2497948556103000*d^2+
1095202331031494671297669562170740521263616657867835727/201892377408609888000*d
^4+509577592485862409373525585898589162816912713954867/77079555445464000*d^3+
6609680932705521464693693266918543066621634323131116167/3567385122341040000000*
d^6+81619901361119434765871709778896157262794357720158679/23376027867192000000*
d^5][r]:
fi:
end:

#Avoi(n,k): the number of 1...k-avoiding permutations of length n. Try
#Avoi(7,4);
Avoi:=proc(n,k)  local d:

if not (type(k, integer) and type(n, integer) and k>0 and n>0 and n<=2*k+1) then
 RETURN(FAIL):

elif n<k then
 n!
else
 n!- subs(d=k,A(d,n-k)):
fi:
end:

#SeqA(k): Inputs a positive integer k, and outputs the list, of length 2*k+1, whose n-th entry is the number of 1...k-avoiding
#permutations of length k. Try:
#SeqA(5);
SeqA:=proc(k) local i:
[seq(Avoi(i,k),i=1..2*k+1)]:
end:


#AvoiPC(n,k): the number of 1...k-avoiding permutations of length n, using pre-computed values if k<=30. Try
#AvoiPC(7,4);
AvoiPC:=proc(n,k)  local d:

if not (type(k, integer) and type(n, integer) and k>0 and n>0 and n<=2*k+1) then
 RETURN(FAIL):

elif n<k then
 n!
elif n=k then
n!-1:
else
 n!- subs(d=k,Apc(d,n-k)):
fi:
end:

#SeqApc(k): Inputs a positive integer k, and outputs the list, of length 2*k+1, whose n-th entry is the number of 1...k-avoiding
#permutations of length k. It uses the pre-computed values of A(d,k) if k<=30. Try:
#SeqApc(5);
SeqApc:=proc(k) local i:
[seq(AvoiPC(i,k),i=1..2*k+1)]:
end:

#Mamar(K): inputs a positive integer K and prints an article with K theorems where the r-th theorem
#is an explicit closed-form expression (of the form (d+r)!-polynomial(d)) for the number of
#1...d-avoiding permutations of length d+r (valid for d>=r). It outputs the list of length K whose r-th entry
#is the expression for the number of 1...d-avoding permutations of length d+r (valid for d>r).
#Try:
#Mamar(6):
Mamar:=proc(K) local d,r,gu,lu,t0:
t0:=time():
print(`Explicit Expressions for the number of permutations of length d+r avoiding an increasing subsequence of length d`):
print(`for r between 1 and`, K, `For SYMBOLIC d (valid for d>= r-1) `):
print(``):
print(`By Shalosh B. Ekhad `):
print(``):
print(`In this article, we will state rigorously-proved explicit expressions for the number of permutations of length d+r`):
print(`that avoid the pattern 12..d, for symbolic d, for r between 1 and`, K, `These expressions are valid for d>=r-1 `):

print(``):
gu:=[]:
for r from 1 to K do

print(`Theorem Number`, r, `:  The number of 1...d-avoiding permutations of length`, d+r, `valid for d>=`,r-1,`is given by `):
lu:=A(d,r):
print((d+r)!-lu):
print(``):
print(`And in Maple notation it is`):
lprint((d+r)!-lu):
print(``):
gu:=[op(gu),lu]:
print(``):
od:

print(`To sum up the list of polynomials describing the number of permutations of length d+r CONTAINING the pattern 1...d`):
print(`valid for d starting at r-1, for r from 1 to`, K, `is `):
print(``):
print(gu):
print(``):
print(`and in Maple notation`):
lprint(gu):

print(`This ends this article, that took`, time()-t0, `seconds.  to generate. `):
gu:
end:

#MamarSeq(K): inputs a positive integer K and outputs the the first 2*d+1 terms of the  enumerating sequences of 1...d-avoiding
#permutations for d from 1 to K. Try:
#MamarSeq(10):
MamarSeq:=proc(K) local i,t0:
t0:=time():
print(`The first few terms of the Enumerating Sequences of Permutations avoding an increasing subsequence of length d for d from 1 to`, K):
print(``):
print(`By Shalosh B. Ekhad `):
print(``):
print(`In this article, we will list the first few terms of the enumerating sequences of permutations avoiding`):
print(`the pattern 1...d, for d from  1 to `, K):
print(``):

for i from 1 to K do
print(`The first`, 2*i+1, `terms of the sequence enumerating permutations without an increasing sequence of length`, i):
print(`are `, SeqA(i) ):
print(``):
od:

print(`This ends this article, that took`, time()-t0, `seconds.  to generate. `):
end:



#Iv(v,t,N): the first N terms of I_v(t). Try; Iv(4,t,10);
Iv:=proc(v,t,N) local j:
add(t^(2*j+v)/j!/(j+v)!,j=0..trunc((N-v)/2)+1):
end:

with(linalg):

#GesselMat(k,t,N):  The Gessel k-1 by k-1 matrix truncated to t^(2*N)
#Try:
#GesselMat(3,t,10);
GesselMat:=proc(k,t,N) local i,j:
[seq([seq(Iv(abs(i-j),t,2*N),j=1..k-1)],i=1..k-1)]:
end:

#SeqIraOld(k,N): Inputs a positive integer k, and a positive integer N
#and outputs the list, of length N, whose n-th entry is the number of 1...k-avoiding
#permutations of length n. It uses Ira Gessel's amazing determinant formula.Try:
#SeqIra(5,30);
SeqIraOld:=proc(k,N) local gu,t,i,j:
gu:=expand(LinearAlgebra[Determinant](Matrix([seq([seq(Iv(abs(i-j),t,2*N),j=1..k-1)],i=1..k-1)]))):

[seq(coeff(gu,t,2*i)*i!^2,i=1..N)]:
end:


#detD(A): the determinant of A using Dodgson's rule
#try:
#detD([[1,2,3],[2,3,4],[3,4,5]]);
detD:=proc(A) local n,i,lumid, lu11,lu12,lu21, lu22:

n:=nops(A):

if n=0 then
 RETURN(1):
fi:

if n=1 then
 RETURN(A[1][1]):
fi:

lumid:=detD([seq([op(2..n-1,A[i])],i=2..n-1)]):

if lu22=0 or lu22=FAIL then
 RETURN(FAIL):
fi:

lu11:=detD([seq([op(1..n-1,A[i])],i=1..n-1)]):
if lu11=FAIL then
 RETURN(FAIL):
fi:

lu12:=detD([seq([op(2..n,A[i])],i=1..n-1)]):
if lu12=FAIL then
 RETURN(FAIL):
fi:

lu21:=detD([seq([op(1..n-1,A[i])],i=2..n)]):
if lu21=FAIL then
 RETURN(FAIL):
fi:

lu22:=detD([seq([op(2..n,A[i])],i=2..n)]):
if lu22=FAIL then
 RETURN(FAIL):
fi:

normal((lu11*lu22-lu12*lu21)/lumid):

end:


#RanMatN(k,N): a random k by k matrix with numerical entries from 1 to N. Try:
#RandMatN(5,20);
RanMatN:=proc(k,N) local ra,i,j:
ra:=rand(1..N):
[seq([seq(ra(),i=1..k)],j=1..k)]:
end:

#RanMatP(k,N,t,d): a random k by k matrix with polynomial in t of degree d with coefficients from 1 to N. Try:
#RandMatP(5,20);
RanMatP:=proc(k,N,t,d) local ra,i,j,r:
ra:=rand(1..N):
[seq([seq(add(ra()*t^r,r=0..d),i=1..k)],j=1..k)]:
end:


#detTP(M,t,N): the determinant of the matrix M of polynomials in the variable t truncated to the t^N
#done directly. Try:
#detTP(GesselMat(5,t,30),t,60);
detTP:=proc(M,t,N) local  gu,i:
gu:=expand(det(M)):
add(coeff(gu,t,i)*t^i,i=0..N):
end:






#detTPD(A,t,N): the determinant of a matrix A whose entries are polynomials using Dodgson's rule, truncated to t^N
#try:
#detTPD(GesselMat(5,t,30),t,60);
detTPD:=proc(A,t,N) local n,i,lumid, lu11,lu12,lu21, lu22,ku:

n:=nops(A):

if n=0 then
 RETURN(1):
fi:

if n=1 then
 RETURN(A[1][1]):
fi:

lumid:=detTPD([seq([op(2..n-1,A[i])],i=2..n-1)],t,N):

if lu22=0 or lu22=FAIL then
 RETURN(FAIL):
fi:

lu11:=detTPD([seq([op(1..n-1,A[i])],i=1..n-1)],t,N):
if lu11=FAIL then
 RETURN(FAIL):
fi:

lu12:=detTPD([seq([op(2..n,A[i])],i=1..n-1)],t,N):
if lu12=FAIL then
 RETURN(FAIL):
fi:

lu21:=detTPD([seq([op(1..n-1,A[i])],i=2..n)],t,N):
if lu21=FAIL then
 RETURN(FAIL):
fi:

lu22:=detTPD([seq([op(2..n,A[i])],i=2..n)],t,N):
if lu22=FAIL then
 RETURN(FAIL):
fi:

ku:=(lu11*lu22-lu12*lu21)/lumid:
ku:=taylor(ku,t=0,N+20):

add(coeff(ku,t,i)*t^i,i=0..N):


end:


#SeqIraD(k,N): Same as SeqIra(k,N) but hopefully faster, since it uses Dodgson's rule.
#Inputs a positive integer k, and a positive integer N
#and outputs the list, of length N, whose n-th entry is the number of 1...k-avoiding
#permutations of length n. It uses Ira Gessel's amazing determinant formula.Try:
#SeqIraD(5,30);
SeqIraD:=proc(k,N) local gu,t,i,j:

gu:=expand(detTPD([seq([seq(Iv(abs(i-j),t,2*N),j=1..k-1)],i=1..k-1)],t,2*N+4   )  ):
[seq(coeff(gu,t,2*i)*i!^2,i=1..N)]:
end:

#SeqIra(k,N): Inputs a positive integer k, and a positive integer N
#and outputs the list, of length N, whose n-th entry is the number of 1...k-avoiding
#permutations of length n. It uses Ira Gessel's amazing determinant formula.Try:
#SeqIra(5,30);
SeqIra:=proc(k,N) local gu,t,i,j, R:
    # define an appropriate polynomial ring
    R := table():
    R[`0`] := 0:
    R[`1`] := 1:
    R[`+`] := `+`:
    R[`-`] := `-`:
    R[`*`] := proc(p, q): return add(coeff(p*q, t, i)*t^i, i=0..2*N): end:
    R[`=`] := proc(p, q): return evalb(p = q): end:

    gu:=expand(LinearAlgebra[Generic][Determinant][R](Matrix([seq([seq(Iv(abs(i-j),t,2*N),j=1..k-1)],i=1..k-1)]))):

    [seq(coeff(gu,t,2*i)*i!^2,i=1..N)]:
end:


#LeadingIra(m,k,r): Inputs symbols m and k, and a non-negative integer, r, outputs, the r+1 leading terms of
#of the degree -2k polynomial in m enumerating permutations of length m+k that contain at least one increasing
#subsequence of length m. To reproduce Proposition 9.6 of Nigel Ray and Julian West's   article 
#"Posets of matrices and permutations with forbidden subsequences"`):
#`Annals of combinatorics 7 (2003), 55-88, type: 
#LeadingIra(m,k,1);
#To get the first 8 leading terms, type: 
#LeadingIra(m,k,8);

LeadingIra:=proc(m,k,r) local gu,gu1,k1,r1,x,lu1,lu,i:

gu:=[seq(A(m,k1),k1=1..2*r+4)]:

lu:=0:

for r1 from 0 to r do
 gu1:=[seq(i!*coeff(gu[i],m,2*i-r1),i=1..nops(gu))]:

 lu1:=GuessPol(gu1,k,1):

 if lu1=0 or lu1=FAIL then
  RETURN(m^(2*k)/k!*subs(x=1/m,lu)):
  else
   lu:=lu+x^r1*factor(lu1):
 fi:

od:

m^(2*k)/k!*subs(x=1/m,lu):
end:

#LeadingIra1(x,k,r): 
LeadingIra1:=proc(x,k,r) local gu,gu1,k1,r1,lu1,lu,i,m:

gu:=[seq(A(m,k1),k1=1..2*r+8)]:

lu:=0:

for r1 from 0 to r do
 gu1:=[seq(i!*coeff(gu[i],m,2*i-r1),i=1..nops(gu))]:

 lu1:=GuessPol(gu1,k,1):

 if lu1=0 or lu1=FAIL then
  RETURN(lu):
  else
   lu:=lu+x^r1*factor(lu1):
 fi:

od:

lu:
end:


#LeadingIraV(m,k,r): Verbose form of  LeadingIra(m,k,r) (q.v.). Try:
LeadingIraV(m,k,2);
LeadingIraV:=proc(m,k,r) local gu,x,t0:

t0:=time():
gu:=LeadingIra1(x,k,r):

print(``):
print(`The first`, r+1 , `Leading terms of the polynomial expression for the number of permutations of length`, m+k, `that contain an inreasing`):
print(`sequence of length m`):
print(``):
print(`By Shalosh B. Ekhad`):
print(``):
print(`In their beautiful article `):
print(`"Posets of matrices and permutations with forbidden subsequences", Annals of combinatorics 7 (2003), 55-88`):
print(`Nigel Ray and Julian West stated and proved the first two leading terms in the polynomial described in the title`):
print(` here  we state the (proved!) extension to the leading`, r+1 , ` terms. `):

gu:=m^(2*k)/k!*subs(x=1/m,gu):
print(`These are `):
print(``):
print(gu):
print(``):
print(`and in Maple notation: `):
lprint(gu):
print(``):
print(`This ends this article that took`, time()-t0, `seconds. `):

end: