# à réécrire avec &* > with(StringTools): Warning, the assigned name Group now has a global binding > # puiss : puissance nième d'un mot w > puiss:=proc(w,n) local res,i : res:=w : for i to n-1 do > res:=cat(w,res) od : res end; puiss := proc(w, n) local res, i; res := w; for i to n - 1 do res := cat(w, res) end do; res end proc > # elementary normal form > enf:=proc(S) local i,res,l;res:=S:if S=du then res:=ud+1 else for i to > length(S)-1 do if substring(S,i..i+1)=du then > res:=cat(substring(S,1..i-1),ud,substring(S,i+2..length(S))) > +cat(substring(S,1..i-1),substring(S,i+2..length(S))):i:=length(S)-1 > else fi od fi: res end: > # La même linéarisée. > lenf:=proc(P) local j,res;if type(P,`+`) then res:=lenf(op(1,P)): for > j from 2 to nops(P) do res:=res+lenf(op(j,P)) od elif type(P,`*`) then > res:=op(1,P)*lenf(op(2,P)) elif type(P,symbol) then res:=enf(P) else > res:=expand(P) fi:res end: > # NF normal form > NF:=proc(P) local i,Q;Q:=P:for i to ceil(length(P)/2)^2 do Q:=lenf(Q) > od:Q end; NF := proc(P) local i, Q; Q := P; for i to ceil(1/2*length(P))^2 do Q := lenf(Q) end do; Q end proc > with(combinat): Warning, the protected name Chi has been redefined and unprotected # Bonson String aléatoire de taille <=N, BSA(N) > HW:=proc(N) cat(d,op(subs({1=d,0=u},convert(N,base,2))),u) end; HW := proc(N) cat(d, op(subs({1 = d, 0 = u}, convert(N, base, 2))), u) end proc > BSA:=proc(N) HW(rand(0..2^(N))()) end; BSA := proc(N) HW(rand(0 .. 2^N)()) end proc > BSA(4); duddu # # W2M(w,x) : Conversion élémentaire d'un mot en x^(nombre de d) > > W2M:=proc(w,x) local i,c;c:=1:for i to length(w) do if > substring(w,i)=d then c:=c*x else fi od :c end; W2M := proc(w, x) local i, c; c := 1; for i to length(w) do if substring(w, i) = d then c := c*x else end if end do; c end proc > F2P:=proc(F,x) local j,res;if type(F,`+`) then res:=F2P(op(1,F),x): > for j from 2 to nops(F) do res:=res+F2P(op(j,F),x) od elif type(F,`*`) > then res:=op(1,F)*F2P(op(2,F),x) elif type(F,symbol) then > res:=W2M(F,x) else res:=expand(F) fi:sort(res) end: > F2P(NF(puiss(ud,6)),x); 6 5 4 3 2 x + 15 x + 65 x + 90 x + 31 x + x > sort(SP(6,y)); SP(6, y) > CE(uddududu,z); CE(uddududu, z) # SP : Polynômes de Stirling SP(r,y)=somme(c=0..r) St2(r,c)y^c > SP:=proc(r,y) sum(stirling2(r,c)*y^c,c=0..r) end; SP := proc(r, y) sum(stirling2(r, c)*y^c, c = 0 .. r) end proc > SP(4,y); 2 3 4 y + 7 y + 6 y + y # Polynômes de Stirling Généralisés SP(r,y)=somme(c=0..r) St2(r,c)y^c # par la formule (32) > FG:=(x,y,r)->exp(y*((1/(1-(r-1)*x))^(1/(r-1))-1)); / / 1 \ \ | |-----| | | \r - 1/ | |/ 1 \ | FG := (x, y, r) -> exp(y ||-------------| - 1|) \\1 - (r - 1) x/ / # Matrix Stringology > seq([k,F2P(NF(puiss(uudud,k)),y)],k=0..7); 2 2 4 3 2 [0, y + y], [1, y + y], [2, y + 8 y + 14 y + 4 y], 6 5 4 3 2 8 [3, y + 21 y + 138 y + 330 y + 252 y + 36 y], [4, y 7 6 5 4 3 2 + 40 y + 576 y + 3744 y + 11304 y + 14688 y + 6624 y 10 9 8 7 6 + 576 y], [5, y + 65 y + 1640 y + 20680 y + 140040 y 5 4 3 2 + 510120 y + 950400 y + 806400 y + 244800 y + 14400 y], 12 11 10 9 8 [6, y + 96 y + 3750 y + 77700 y + 934200 y 7 6 5 4 + 6708960 y + 28607760 y + 69876000 y + 90936000 y 3 2 14 13 + 55296000 y + 12182400 y + 518400 y], [7, y + 133 y 12 11 10 9 + 7434 y + 229194 y + 4302900 y + 51283260 y 8 7 6 + 392852880 y + 1918884240 y + 5817601440 y 5 4 3 + 10419948000 y + 10156406400 y + 4686595200 y 2 + 787449600 y + 25401600 y] > > Sw:=proc(w,n,k) coeff(F2P(NF(puiss(w,k)),y),y,n) end; Sw := proc(w, n, k) coeff(F2P(NF(puiss(w, k)), y), y, n) end proc > with(LinearAlgebra): Warning, the name Map has been rebound > matrix(7,7,(j,i)->Sw(ud,i-1,j-1)); [0 1 0 0 0 0 0] [ ] [0 1 0 0 0 0 0] [ ] [0 1 1 0 0 0 0] [ ] [0 1 3 1 0 0 0] [ ] [0 1 7 6 1 0 0] [ ] [0 1 15 25 10 1 0] [ ] [0 1 31 90 65 15 1] > matrix(7,7,(j,i)->Sw(udu,i-1,j-1)); [ 1 1 0 0 0 0 0] [ ] [ 1 1 0 0 0 0 0] [ ] [ 2 4 1 0 0 0 0] [ ] [ 6 18 9 1 0 0 0] [ ] [ 24 96 72 16 1 0 0] [ ] [120 600 600 200 25 1 0] [ ] [720 4320 5400 2400 450 36 1] > NF(duu);NF(duuduu); uud + 2 u uuuudd + 6 uuud + 6 uu > matrix(7,7,(j,i)->Sw(duu,i-1,j-1)); [ 2 1 0 0 0 0 0] [ ] [ 2 1 0 0 0 0 0] [ ] [ 6 6 1 0 0 0 0] [ ] [ 24 36 12 1 0 0 0] [ ] [ 120 240 120 20 1 0 0] [ ] [ 720 1800 1200 300 30 1 0] [ ] [5040 15120 12600 4200 630 42 1] > matrix(7,7,(j,i)->Sw(udduud,i-1,j-1)); Warning, computation interrupted > M1:=Matrix(4,8,(j,i)->Sw(udduud,i,j)); M1 := [2 , 4 , 1 , 0 , 0 , 0 , 0 , 0] [4 , 68 , 146 , 86 , 17 , 1 , 0 , 0] [8 , 856 , 6916 , 13988 , 10536 , 3508 , 549 , 39] [16 , 10352 , 269576 , 1431912 , 2650324 , 2189412 , 920500 , 211192] > V1:=Vector(1..10,1); [1] [ ] [1] [ ] [1] [ ] [1] [ ] [1] V1 := [ ] [1] [ ] [1] [ ] [1] [ ] [1] [ ] [1] > ?Multiply > MatrixVectorMultiply(M1,V1); [ 4] [ ] [ 157] [ ] [ 14712] [ ] [ 2485381] [ ] [657310956] > M1:=Matrix(5,10,(j,i)->Sw(uduuuud,i,j)):MatrixVectorMultiply(M1,V1); [ 5] [ ] [ 219] [ ] [ 22073] [ ] [ 3937737] [ ] [1087688521] > M1:=Matrix(5,10,(j,i)->Sw(duuuuud,i,j)):MatrixVectorMultiply(M1,V1); [ 6] [ ] [ 291] [ ] [ 31486] [ ] [ 5930561] [ ] [1711777006] > M1:=Matrix(5,10,(j,i)->Sw(uuuuudd,i,j)):MatrixVectorMultiply(M1,V1); [ 1] [ ] [ 31] [ ] [ 2481] [ ] [ 371881] [ ] [89281461] >