Linear Algebra and its Applications 449 (2014) 43–59
Contents lists available at ScienceDirect
Linear Algebra and its Applications
www.elsevier.com/locate/laa
Enumeration of compositions according to the sumof the values of the first letters of the occurrencesof a 2-letter pattern
Walaa Asakly, Toufik Mansour ∗
Department of Mathematics, University of Haifa, 3498838 Haifa, Israel
a r t i c l e i n f o a b s t r a c t
Article history:Received 18 September 2013Accepted 14 February 2014Available online 4 March 2014Submitted by R. Brualdi
MSC:05A1515A0615A15
Keywords:RisesWeak-risesLevelsDescentsWeak-descentsGenerating functionsCramer’s method
A composition π = π1π2 · · ·πm of a positive integer n isan ordered collection of one or more positive integers whosesum is n. The number of summands, namely m, is calledthe number of parts of π. We say that π contains a rise,a weak-rise, a level, a descent, or a weak-descent at positioni according to whether πi < πi+1, πi � πi+1, πi = πi+1,πi > πi+1, or πi � πi+1. Using linear algebra, we determineformulas for generating functions that count compositions ofn with m parts, according to the numbers of rises, weak-rises,levels, descents, and weak-descents, and according to the sum,over all occurrences of the rises, weak-rises, levels, descents,and weak-descents, of the first integers in their respectiveoccurrences.
© 2014 Elsevier Inc. All rights reserved.
1. Introduction
A composition π = π1π2 · · ·πm of a positive integer n ∈ N is an ordered collection ofone or more positive integers whose sum is n. (That is, π is a partition of n in which
* Corresponding author.E-mail addresses: [email protected] (W. Asakly), [email protected] (T. Mansour).
http://dx.doi.org/10.1016/j.laa.2014.02.0280024-3795/© 2014 Elsevier Inc. All rights reserved.
44 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
Table 1Explicit formulas for the average sum of the values of the first letters of theoccurrences of σ in compositions of Cn, where σ ∈ Pat2.
σ ∈ Pat2 Average sum of the values of the first letters of theoccurrences of σ in compositions of Cn
rise 227 (3n − 7) + 1
2n+1 − 127·2n+1 (6n − 1)(−1)n, n � 3
descent 127 (15n− 38) + 3
2n+1 − 127·2n+1 (6n + 5)(−1)n, n � 1
level 227 (3n − 1) + 1
27·2n−1 (3n + 1)(−1)n, n � 1
weak-rise 427 (3n − 4) + 1
2n+1 + 127·2n+1 (6n + 5)(−1)n, n � 3
weak-descent 127 (21n− 40) + 3
2n+1 + 127·2n+1 (6n− 1)(−1)n, n � 1
the parts are ordered.) The number m of summands is called the number of parts of π.For example, the compositions of the number 4 are 4, 31, 13, 22, 211, 121, 112 and 1111.We denote the set of all compositions of n or with exactly m parts, or with exactly m
parts in [d] = {1, 2, . . . , d}, by Cn, or Cn,m, or C[d]n,m, respectively. Clearly, the number
of compositions of n is given by |Cn| = 2n−1.Let π = π1π2 · · ·πm be any composition of n with exactly m parts in N and let
σ = σ1σ2 · · ·σs be any word of length s, where m � s. An occurrence of σ in π is asubword πiπi+1 · · ·πi+s−1 which is order isomorphic to σ, i.e., πi−1+a < πi−1+b if andonly if σa < σb for all 1 � a < b � s. In this context, the word σ is usually called apattern of length s (or an s-letter pattern). We denote the number of the occurrencesof σ in π by occσ(π) and we denote the sum over all occurrences of σ in π by sflσ(π)of the values of the first letters. For example, the occurrences of the pattern 112 in thecomposition π = 1122411 of 12 are 112 and 224, and sfl112(π) = 1 + 2 = 3.
Rises, weak-rises, levels, descents, and weak-descents can be regarded as the simplestof patterns, namely the 2-letter patterns. A rise corresponds to the subword pattern 12.A weak-rise corresponds to the subword patterns 11 and 12, a level to the subwordpattern 11, a descent to the subword pattern 21, and a weak-descent to the subwordpatterns 11 and 21.
Alladi and Hoggatt [1] studied the generating function for the number of compositionsof n with parts in {1, 2}, and they showed that the number of rises, levels and descents,exhibit connections with the Fibonacci sequence. Chinn and Heubach [7] generalizedto parts in {1, k}, and Chinn, Grimaldi and Heubach [5] extended them to parts in N
(for other extensions, see [6,8,9,11,12]). Later, Heubach and Mansour [10] studied thegenerating function for the number of compositions of n with exactly m parts accordingto the number of occurrences of the patterns 11, 12 and 21 (for other reference, see also[2–4] and references therein).
In this paper, for any fixed pattern σ ∈ Pat2 = {Rise,Weak-rise,Level,Descent,Weak-descent}, we will derive the generating functions for the number of compositions,the number of parts, and the statistics occσ and sflσ. This unified framework generalizesearlier work by several authors. From this, we obtain generating functions and explicitformulas for the average sum of the values of the first letters of the occurrences of σ incompositions of n, see Table 1.
W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 45
Finally, we use our results to derive the average sum of the values of the first lettersof the occurrences of σ in words of [d]n, where σ ∈ Pat2.
2. Sum of the values of the first letters of the occurrence of a pattern in Pat2
This section is divided into several subsections, where in each subsection we study afixed 2-letter pattern from the set Pat2.
2.1. Rises
We define ris = occRise and sris = sflRise. Let Cris(x, y, u, v) be the generating functionfor the number of compositions of n with exactly m parts according to the statistics risand sris, that is,
Cris = Cris(x, y, u, v) =∑
n,m�0
∑π∈Cn,m
xnymusris(π)vris(π).
In this section, we find an explicit formula for the generating function Cris. In order to dothat, we denote the generating function for the number of compositions π = π1π2 · · ·πm
of n with exactly m parts such that πj = aj for all j = 1, 2, . . . , s according to thestatistics ris and sris by
Cris(a1 · · · as) = Cris(x, y, u, v|a1 · · · as)
=∑
n,m�0
∑π=a1···asπs+1···πs∈Cn,m
xnymusris(π)vris(π).
Clearly,
Cris(x, y, u, v) = 1 +∑a�1
Cris(a). (1)
Firstly, we find a recurrence relation for the generating function Cris(a). By the defi-nitions
Cris(a) = xay +a∑
b=1
Cris(ab) +∑
b�a+1
Cris(ab)
= xay + xaya∑
b=1
Cris(b) + xayvua∑
b�a+1
Cris(b).
By (1), we obtain that
Cris(a) = xay(1 − vua
)+ xay
(1 − vua
) a∑Cris(b) + xayvuaCris. (2)
b=1
46 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
Now, we restrict ourselves to study the generating function C[d]ris (x, y, u, v) for the
number of compositions of n with exactly m parts in [d] according to the statistics risand sris, that is,
C[d]ris = C
[d]ris (x, y, u, v) =
∑n,m�0
∑π∈C
[d]n,m
xnymusris(π)vris(π).
Theorem 1. For all i = 1, 2, . . . , d,
C[d]ris (i) = mi + αi
1 − αi+
(ni + βi
1 − αi
)C
[d]ris ,
where mi =∑i−1
j=1αiαj∏i
k=j(1−αk) , ni =∑i−1
j=1αiβj∏i
k=j(1−αk) , αi = xiy(1−vui) and βi = xiyvui.Moreover,
C[d]ris = C
[d]ris (x, y, u, v) =
1 +∑d
i=1(mi + αi
1−αi)
1 −∑d
i=1(ni + βi
1−αi).
Proof. By (2) we have⎧⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎩
C[d]ris (1) = α1 + β1C
[d]ris + α1C
[d]ris (1),
C[d]ris (2) = α2 + β2C
[d]ris + α2
2∑j=1
C[d]ris (j)
...
C[d]ris (d) = αd + βdC
[d]ris + αd
d∑j=1
C[d]ris (j).
The above system of equations can be written in a matrix form as follows
A
⎛⎜⎜⎜⎜⎜⎝
C[d]ris (1)
C[d]ris (2)...
C[d]ris (d)
⎞⎟⎟⎟⎟⎟⎠ =
⎛⎜⎜⎜⎜⎜⎝
α1 + β1C[d]ris
α2 + β2C[d]ris
...αd + βdC
[d]ris
⎞⎟⎟⎟⎟⎟⎠ , A =
⎛⎜⎜⎜⎜⎝
1 − α1 0 · · · 0−α2 1 − α2 0
. . . . . .−αd −αd · · · 1 − αd
⎞⎟⎟⎟⎟⎠ .
We solve this system by Cramer’s method and we obtain
C[d]ris (i) =
∏dj=i+1(1 − αj)∏dj=1(1 − αj)
∣∣∣∣∣∣∣∣∣∣∣∣
1 − α1 0 · · · 0 γ1−α2 1 − α2 0 γ2
. . . . . ....
−α−1 −αi−1 · · · 1 − αi−1 γi−1−α −α · · · −α γ
∣∣∣∣∣∣∣∣∣∣∣∣,
i i i i
W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 47
where γj = αj+βjC[d]ris . Hence, by determining the determinant by the rightmost column,
we derive
C[d]ris (i) = 1∏i
j=1(1 − αj)
(αi
i−1∑j=1
γj
j−1∏k=1
(1 − αk) + γi
i−1∏k=1
(1 − αk)),
which is equivalent to
C[d]ris (i) =
i−1∑j=1
αiγj∏ik=j(1 − αk)
+ γi1 − αi
,
for all i = 1, 2, . . . , d. Hence, by rewriting the generating function C[d]ris (i) in terms of ni
and mi, we obtain that
C[d]ris (i) = mi + αi
1 − αi+
(ni + βi
1 − αi
)C
[d]ris ,
for all i = 1, 2, . . . , d. By the fact that C [d]ris = 1+
∑di=1 C
[d]ris (i), we complete the proof. �
By taking d → ∞ in Theorem 1, we obtain the main result of this section.
Theorem 2. Let αi = xiy(1 − vui) and βi = xiyvui, for all i � 1. Then
Cris(x, y, u, v) =1 +
∑∞i=1 αi( 1
1−αi+
∑i−1j=1
αj∏ik=j(1−αk) )
1 −∑∞
i=1(βi
1−αi+ αi
∑i−1j=1
βj∏ik=j(1−αk) )
.
We are now in a position to find the average of the sum of the values of first lettersof the rises in all the compositions of n.
Corollary 3. The mean of sris, taken over all compositions of n, is given by
12n−1
∑π∈Cn
sris(π) = 227(3n− 7) + 1
2n+1 − 127 · 2n+1 (6n− 1)(−1)n.
Proof. By differentiating the generating function Cris(x, y, u, 1) with respect to u andevaluating it at u = 1, we obtain
d
duCris(x, y, u, 1)|u=1 = y2x3
(1 + x)2(1 − x)(1 − x− xy)2 ,
which implies
∑ ∑sris(π)xn = x3
(1 + x)2(1 − x)(1 − 2x)2 .
n�0 π∈Cn48 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
By comparing the coefficient of xn, we have
∑π∈Cn
sris(π) = 127(3n− 7)2n + 1
4 − 1108(6n− 1)(−1)n,
which completes the proof. �2.2. Descents
We define des = occDescent and sdes = sflDescent. Let Cdes(x, y, u, v) be the generatingfunction for the number of compositions of n with exactly m parts according to thestatistics des and sdes, that is,
Cdes = Cdes(x, y, u, v) =∑
n,m�0
∑π∈Cn,m
xnymusdes(π)vdes(π).
In this section, we find an explicit formula for the generating function Cdes. In order to dothat, we denote the generating function for the number of compositions π = π1π2 · · ·πm
of n with exactly m parts such that πj = aj for all j = 1, 2, . . . , s according to thestatistics des and sdes by
Cdes(a1 · · · as) = Cdes(x, y, u, v|a1 · · · as)
=∑
n,m�0
∑π=a1···asπs+1···πs∈Cn,m
xnymusdes(π)vdes(π).
Obviously,
Cdes = 1 +∑a�1
Cdes(a). (3)
Now, let us find a recurrence relation for the generating function Cdes(a). By thedefinitions we have
Cdes(a) = xay +∑b�a
Cdes(ab) +∑b<a
Cdes(ab)
= xay + xay∑b�a
Cdes(b) + xayuav∑b<a
Cdes(b).
By (3), we obtain
Cdes(a) = xay(uav − 1
) a−1∑Cdes(b) + xayCdes. (4)
b=1
W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 49
In order to give an explicit formula for the generating function Cdes(a), we restrict ourattention to study the generating function C
[d]des(x, y, u, v) for the number of compositions
of n with exactly m parts in [d] according to the statistics des and sdes, that is
C[d]des = C
[d]des(x, y, u, v) =
∑n,m�0
∑π∈C
[d]n,m
xnymusdes(π)vdes(π).
Theorem 4. For all d � 1,
C[d]des = 1
1 −∑d
i=1 xiy[1 − (1 − uiv)y
∑i−1j=1 x
j∏i−1
k=j+1(1 − xky(1 − ukv))].
Proof. By (4) we have
⎧⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎩
C[d]des(1) = xyC
[d]des,
C[d]des(2) = x2yC
[d]des − α2C
[d]des(1)
...
C[d]des(d) = xdyC
[d]des − αd
d−1∑j=1
C[d]des(j),
where αj = xjy(1 − ujv). The above system of equations can be written in a matrixform as
A
⎛⎜⎜⎜⎜⎜⎝
C[d]des(1)
C[d]des(2)
...C
[d]des(d)
⎞⎟⎟⎟⎟⎟⎠ =
⎛⎜⎜⎜⎜⎝
xy
x2y...
xdy
⎞⎟⎟⎟⎟⎠C
[d]des, A =
⎛⎜⎜⎜⎜⎝
1 0 · · · 0α2 1 · · · 0...
. . ....
αd αd · · · 1
⎞⎟⎟⎟⎟⎠ .
We solve the linear system by Cramer’s method and we obtain
C[d]des(i) =
∣∣∣∣∣∣∣∣∣∣∣∣
1 0 · · · 0 x
α2 1 0 0 x2
. . . . . ....
αi−1 αi−1 · · · 1 xi−1
αi αi · · · αi xi
∣∣∣∣∣∣∣∣∣∣∣∣yC
[d]des,
which implies
C[d]des(i) =
[xi − αi
i−1∑xj
i−1∏(1 − αk)
]yC
[d]des.
j=1 k=j+1
50 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
Hence, by (3), we have
C[d]des − 1 =
d∑i=1
[xiy − αi
i−1∑j=1
xjyi−1∏
k=j+1
(1 − αk)]C
[d]des,
which gives
C[d]des = 1
1 −∑d
i=1[xiy − αi
∑i−1j=1 x
jy∏i−1
k=j+1(1 − αk)],
as required. �By taking d → ∞ in Theorem 1, we obtain the main result of this section.
Theorem 5. For all d � 1,
Cdes(x, y, u, v) = 11 −
∑i�1 x
iy[1 − (1 − uiv)y∑i−1
j=1 xj∏i−1
k=j+1(1 − xky(1 − ukv))].
We are now in a position to find the average of the sum of the values of the first lettersof the descents in all the compositions of n.
Corollary 6. The mean of sdes, taken over all compositions of n, is given by
12n−1
∑π∈Cn
sdes(π) = 127(15n− 38) + 3
2n+1 − 127 · 2n+1 (6n + 5)(−1)n.
Proof. By differentiating the generating function Cdes(x, y, u, 1) with respect to u andevaluating it at u = 1, we obtain
d
duCdes(x, y, u, 1)|u=1 = y2x3(2 + x)
(1 − x)(1 + x)2(1 − x− xy)2 ,
which implies
∑n�0
∑π∈Cn
sdes(π)xn = x3(2 + x)(1 − x)(1 + x)2(1 − 2x)2 .
By comparing the coefficient of xn, we have
∑π∈Cn
sdes(π) = 127(15n− 38)2n−1 + 3
4 − 1108(6n + 5)(−1)n,
which completes the proof. �
W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 51
2.3. Levels
We define lev = occLevel and slev = sflLevel. In this section, we find an explicitformula for the generating function Clev(x, y, u, v) for the number of compositions of nwith exactly m parts according to the statistics lev and slev, that is,
Clev = Clev(x, y, u, v) =∑
n,m�0
∑π∈Cn,m
xnymuslev(π)vlev(π).
To do so, we denote the generating function for the number of compositions π =π1π2 · · ·πm of n with exactly m parts such that πj = aj for all j = 1, 2, . . . , s accordingto the statistics lev and slev by
Clev(a1 · · · as) = Clev(x, y, u, v|a1 · · · as)
=∑
n,m�0
∑π=a1···asπs+1···πs∈Cn,m
xnymuslev(π)vlev(π).
Clearly,
Clev = 1 +∑a�1
Clev(a). (5)
Firstly, we find a recurrence relation for the generating function Clev(a). By the defi-nitions
Clev(a) = xay +∑b�1
Clev(ab) = xay +∑b�=a
Clev(ab) + Clev(aa)
= xay + xay∑b�=a
Clev(b) + xayuavClev(a).
By (5) we obtain
Clev(a) = xayClev
1 + xay(1 − uav) ,
for all a � 1. By summing over a � 1 and using (5), we state the following result.
Theorem 7. We have
Clev(x, y, u, v) = 11 −
∑j�1
xjy1+xjy(1−ujv)
.
Note that, by our above tools, we state that C[d]lev(x, y, u, v) = 1
1−∑d
j=1xjy
1+xjy(1−ujv)
.
We are now in a position to find the average of the sum of the values of the first lettersof the levels in all the compositions of n.
52 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
Corollary 8. The mean of slev, taken over all compositions of n, is given by
12n−1
∑π∈Cn
slev(π) = 227(3n− 1) + 1
27 · 2n−1 (3n + 1)(−1)n.
Proof. By differentiating the generating function Clev(x, y, u, 1) with respect to u andevaluating it at u = 1, we obtain
d
duClev(x, y, u, 1)|u=1 = y2x2
(1 + x)2(1 − x− xy)2 ,
which implies
∑n�0
∑π∈Cn,m
slev(π)xn = x2
(1 + x)2(1 − 2x)2 .
By comparing the coefficient of xn, we have
∑π∈Cn
slev(π) = 127(3n− 1)2n + 1
27(3n + 1)(−1)n,
which completes the proof. �2.4. Weak-rises
We define wris = occWeak−rise and swris = sflWeak−rise. Let Cwris(x, y, u, v) be thegenerating function for the number of compositions of n with exactly m parts accordingto the statistics wris and swris, that is,
Cwris = Cwris(x, y, u, v) =∑
n,m�0
∑π∈Cn,m
xnymuswris(π)vwris(π).
In this section, we find an explicit formula for the generating function Cwris. In order to dothat, we denote the generating function for the number of compositions π = π1π2 · · ·πm
of n with exactly m parts such that πj = aj for all j = 1, 2, . . . , s according to thestatistics wris and swris by
Cwris(a1 · · · as) = Cwris(x, y, u, v|a1 · · · as)
=∑
n,m�0
∑π=a1···asπs+1···πs∈Cn,m
xnymuswris(π)vwris(π).
Clearly,
Cwris(x, y, u, r) = 1 +∑
Cwris(a). (6)
a�1W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 53
Firstly, we find a recurrence relation for the generating function Cwris(a). Using
Cwris(a) = xay +a−1∑b=1
Cwris(ab) +∑b�a
Cwris(ab)
= xay + xaya−1∑b=1
Cwris(b) + xayuav∑b�a
Cwris(b)
together with (6), we obtain
Cwris(a) = xay(1 − uav
)+ xay
(1 − uav
) a−1∑b=1
Cwris(b) + xayuavCwris. (7)
In order to give an explicit formula for the generating function Cwris(a), we restrict ourattention to the generating function C
[d]wris(x, y, u, v) for the number of compositions of n
with exactly m parts in [d] according to the statics wris and swris, that is
C[d]wris = C
[d]wris(x, y, u, v) =
∑n,m�0
∑π∈C
[d]n,m
xnymuswris(π)vwris(π).
Theorem 9. If we define αi = xiy(1 − uiv) and βi = xiyuiv, for all i = 1, 2, . . . , d, then
C[d]wris(x, y, u, v) =
1 +∑d
i=1(αi + αi
∑i−1j=1 αj
∏i−1k=j+1(1 + αk))
1 −∑d
i=1(βi + αi
∑i−1j=1 βj
∏i−1k=j+1(1 + αk))
.
Proof. By (7) we have
⎧⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎩
C[d]wris(1) = α1 + β1C
[d]wris,
C[d]wris(2) = α2 + α2C
[d]wris(1) + β2C
[d]wris
...
C[d]wris(d) = αd + αd
d−1∑j=1
C[d]wris(j) + βdC
[d]wris.
The above system of equations can be written in a matrix form as
A
⎛⎜⎜⎜⎜⎜⎝
C[d]wris(1)
C[d]wris(2)
...C
[d]wris(d)
⎞⎟⎟⎟⎟⎟⎠ =
⎛⎜⎜⎜⎜⎜⎝
α1 + β1C[d]wris
α2 + β2C[d]wris
...αd + βdC
[d]wris
⎞⎟⎟⎟⎟⎟⎠ , A =
⎛⎜⎜⎜⎜⎝
1 0 · · · 0−α2 1 0
. . . . . .−αd −αd · · · 1
⎞⎟⎟⎟⎟⎠ .
54 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
Again, we need to solve the linear system by Cramer’s method
C[d]wris(i) =
∣∣∣∣∣∣∣∣∣∣∣∣
1 0 · · · 0 γ1−α2 1 0 γ2
. . . . . ....
−αi−1 −αi−1 · · · 1 γi−1−αi −αi · · · −αi γi
∣∣∣∣∣∣∣∣∣∣∣∣,
where γj = αj + βjC[d]wris where i = 1, 2, . . . , d. Hence,
C[d]wris(i) = γi + αi
i−1∑j=1
γj
i−1∏k=j+1
(1 + αk).
Summing over i = 1, 2, . . . , d and by (6), we have
C[d]wris − 1 =
d∑i=1
(αi + βiC
[d]wris + αi
i−1∑j=1
(αj + βjC
[d]wris
) i−1∏k=j+1
(1 + αk)),
which implies
C[d]wris =
1 +∑d
i=1(αi + αi
∑i−1j=1 αj
∏i−1k=j+1(1 + αk))
1 −∑d
i=1(βi + αi
∑i−1j=1 βj
∏i−1k=j+1(1 + αk))
,
as claimed. �By taking d → ∞ in Theorem 9, we obtain the main result of this section.
Theorem 10. We define αi = xiy(1 − uiv) and βi = xiyuiv, for all i � 1, then
Cwris(x, y, u, v) =1 +
∑i�1(αi + αi
∑i−1j=1 αj
∏i−1k=j+1(1 + αk))
1 −∑
i�1(βi + αi
∑i−1j=1 βj
∏i−1k=j+1(1 + αk))
.
We are now in a position to find the average of the sum of the values of the first lettersof the weak-rises in all the compositions of n.
Corollary 11. The mean of swris, taken over all compositions of n, is given by
12n−1
∑π∈Cn
swris(π) = 427(3n− 4) + 1
2n+1 + 127 · 2n+1 (6n + 5)(−1)n.
Proof. By differentiating the generating function Cwris(x, y, u, 1) with respect to u andthe setting u = 1, we obtain
dCwris(x, y, u, 1)|u=1 = y2x2
2 2 ,
du (1 − x)(1 + x) (1 − x− xy)W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 55
which implies that the generating function for the total statistic swris in all compositionsof n with exactly m parts is given by
∑n�0
∑π∈Cn
swris(π)xn = x2
(1 − x)(1 + x)2(1 − 2x)2 .
Comparing the coefficient of xn, yields
∑π∈Cn
swris(π) = 427(3n− 4)2n−1 + 1
4 + 1108(6n + 5)(−1)n,
which completes the proof. �2.5. Weak-descents
We define wdes = occWeak-descent and swdes = sflWeak-descent. Let Cwdes(x, y, u, v)be the generating function for the number of compositions of n with exactly m partsaccording to the statistics wdes and swdes, that is,
Cwdes = Cwdes(x, y, u, v) =∑
n,m�0
∑π∈Cn,m
xnymuswdes(π)vwdes(π).
In this section, we find an explicit formula for the generating function Cwdes. In orderto do that, we denote the generating function for the number of compositions π =π1π2 · · ·πm of n with exactly m parts such that πj = aj for all j = 1, 2, . . . , s accordingto the statistics wdes and swdes by
Cwdes(a1 · · · as) = Cwdes(x, y, u, v|a1 · · · as)
=∑
n,m�0
∑π=a1···asπs+1···πs∈Cn,m
xnymuswdes(π)vwdes(π).
Clearly,
Cwdes(x, y, u, d) = 1 +∑a�1
Cwdes(a). (8)
Now, let us find a recurrence relation for the generating function Cwdes(a). Using thedefinitions
Cwdes(a) = xay +a∑
b=1
Cwdes(ab) +∑
b�a+1
Cwdes
= xay + xayuava∑
Cwdes(b) + xay∑
Cwdes(b)
b=1 b�a+156 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
together with by (8), we obtain
Cwdes(a) = xayCwdes − xay(1 − uav
) a∑b=1
Cwdes(b). (9)
In order to give an explicit formula for the generating function Cwdes(a), we restrict ourattention to the generating function C
[d]wdes(x, y, u, v) for the number of compositions of n
with exactly m parts in [d] according to the statics wdes and swdes, that is
C[d]wdes = C
[d]wdes(x, y, u, v) =
∑n,m�0
∑π∈C
[d]n,m
xnymuswdes(π)vwdes(π).
Theorem 12. We have
C[d]wdes(x, y, u, v)
= 11 − y
∑di=1(
xi
1+xiy(1−uiv) − xiy(1 − uiv)∑i−1
j=1xj∏i
k=j(1+xky(1−ukv)) ).
Proof. By (9) we have
⎧⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎩
C[d]wdes(1) = −α1C
[d]wdes(1) + xyC
[d]wdes,
C[d]wdes(2) = −α2
2∑j=1
C[d]wdes(j) + x2yC
[d]wdes
...
C[d]wdes(d) = −αd
k−1∑j=1
C[d]wdes(j) + xdyC
[d]wdes,
where αj = xjy(1 − ujv). The above system of equations can be written in a matrixform as
A
⎛⎜⎜⎜⎜⎜⎝
C[d]wdes(1)
C[d]wdes(2)
...C
[d]wdes(d)
⎞⎟⎟⎟⎟⎟⎠ =
⎛⎜⎜⎜⎜⎝
x
x2
...xk
⎞⎟⎟⎟⎟⎠ yC
[d]wdes, A =
⎛⎜⎜⎜⎜⎝
1 + α1 0 · · · 0α2 1 + α2 · · · 0...
. . ....
αd αd · · · 1 + αd
⎞⎟⎟⎟⎟⎠ .
Again, we solve the linear system using Cramer’s method and obtain
W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 57
C[d]wdes(i) =
∏dj=i+1(1 + αj)∏kj=1(1 + αj)
∣∣∣∣∣∣∣∣∣∣∣∣
1 + α1 0 · · · 0 x1
α2 1 + α2 0 x2
. . . . . ....
αi−1 αi−1 · · · 1 + αi−1 xi−1
αi αi · · · αi xi
∣∣∣∣∣∣∣∣∣∣∣∣yC
[d]wdes.
Thus,
C[d]wdes(i) = yC
[d]wdes∏i
j=1(1 + αj)
(xi
i−1∏j=1
(1 + αj) − αi
i−1∑j=1
xj
j−1∏k=1
(1 + αk)),
which is equivalent to
C[d]wdes(i) = yC
[d]wdes
(xi
1 + αi− αi
i−1∑j=1
xj∏ik=j(1 + αk)
).
By summing over i = 1, 2, . . . , d and by (8), we have
C[d]wdes − 1 = yC
[d]wdes
d∑i=1
(xi
1 + αi− αi
i−1∑j=1
xj∏ik=j(1 + αk)
),
which implies
C[d]wdes = 1
1 − y∑d
i=1(xi
1+αi− αi
∑i−1j=1
xj∏ik=j(1+αk) )
,
as claimed. �By taking d → ∞ in Theorem 12, we obtain the main result of this section.
Theorem 13. We have
Cwdes(x, y, u, v) = 11 − y
∑i�1(
xi
1+xiy(1−uiv) − xiy(1 − uiv)∑i−1
j=1xj∏i
k=j(1+xky(1−ukv)) ).
We are now in a position to find the average of the sum of the values of the first lettersof the weak-descents in all the compositions of n.
Corollary 14. The mean of swdes, taken over all compositions of n, is given by
12n−1
∑π∈Cn
swdes(π) = 727(21n− 40) + 3
2n+1 + 127 · 2n+1 (6n− 1)(−1)n.
58 W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59
Proof. By differentiating the generating function Cwdes(x, y, u, 1) with respect to u andthen setting u = 1, we obtain
d
duCwdes(x, y, u, 1)|u=1 = y2x2(1 + x + x2)
(1 − x)(1 + x)2(1 − x− xy)2 ,
which implies
∑n�0
∑π∈Cn,m
swdes(π)xn = x2(1 + x + x2)(1 − x)(1 + x)2(1 − 2x)2 .
Comparing the coefficient of xn, we obtain
∑π∈Cn
swdes(π) = 727(21n− 40)2n−1 + 3
4 + 1108(6n− 1)(−1)n,
which completes the proof. �We end this paper by applying our results to obtain enumeration of words over al-
phabet [d] according to our statistics. For instance, Theorem 1 with x = 1 gives thegenerating function W ris
d (y, u, v) for the number of words of length n over alphabet [d]according to the statistics ris and sris, namely
W risd (y, u, v) =
∑n�0
∑π∈[d]n
xnusrisvris,
is given by
W risd (y, u, v) =
1 +∑d
i=1(y(1−vui)
1−y(1−vui) +∑i−1
j=1y2(1−vui)(1−vuj)∏ik=j(1−y(1−vuk)) )
1 −∑d
i=1(yvui
1−y(1−vui) +∑i−1
j=1y2vuj(1−vui)∏i
k=j(1−y(1−vuk)) ).
By differentiating the generating function W risd (y, u, 1) respect to u and evaluating it at
u = 1, we obtain
d
duW ris
d (y, u, 1)|u=1 =y2(d+1
3)
(1 − yd)2 =∑n�2
(n− 1)(d + 1
3
)dn−2yn,
which implies that the average sum of the values of the first letters in the rises in allwords of [n]d is given by (n − 1)d
2−16d . Similarly, we can state the average sum of the
values of the first letters in the occurrences of σ ∈ Pat2 in all words of [n]d, see Table 2.
W. Asakly, T. Mansour / Linear Algebra and its Applications 449 (2014) 43–59 59
Table 2Explicit formulas for the average sum of the values of the first letters of theoccurrences of σ in all words of [n]d, where σ ∈ Pat2.
σ ∈ Pat2 Average sum of the values of the first letters ofthe occurrences of σ in all words of [n]d
rise (n − 1) d2−16d
descent (n − 1) d2−13d
level (n − 1) d+12d
weak-rise (n − 1) (d+1)(d+2)6d
weak-descent (n − 1) (d+1)(2d+1)6d
Acknowledgements
The authors are grateful to the anonymous referee for his or her helpful comments.Special thanks to Jonathan L. Gross for reading previous version of the present paperand for his helpful comments.
References
[1] K. Alladi, V.E. Hoggatt, Compositions with ones and twos, Fibonacci Quart. 13 (3) (1975) 233–239.[2] M. Archibald, A. Knopfmacher, The largest missing value in a composition of an integer, Discrete
Math. 311 (2011) 723–731.[3] C. Brennan, Knopfmacher, The distribution of ascents of size d or more in compositions, Discrete
Math. Theor. Comput. Sci. 11 (2009) 1–10.[4] C. Brennan, A. Knopfmacher, The first ascent of size d or more in compositions, Discrete Math.
Theor. Comput. Sci. Proc. AG (2006), Nancy.[5] P. Chinn, R. Grimaldi, S. Heubach, Rises, levels, drops, and “+” signs in compositions: extensions
of a paper by Alladi and Hoggatt, Fibonacci Quart. 41 (3) (2003) 229–239.[6] P. Chinn, S. Heubach, Compositions of n with no occurrence of k, Congr. Numer. 164 (2003) 33–51.[7] P. Chinn, S. Heubach, (1, k)-compositions, Congr. Numer. 164 (2003) 183–194.[8] R.P. Grimaldi, Compositions with odd summands, Congr. Numer. 142 (2000) 113–127.[9] S. Heubach, T. Mansour, Compositions of n with parts in a set, Congr. Numer. 168 (2004) 127–143.
[10] S. Heubach, T. Mansour, Counting rises, levels, and drops in compositions, Integers 5 (2005), Ar-ticle A11.
[11] S. Heubach, T. Mansour, Combinatorics of Compositions and Words, CRC Press, Boca Raton, FL,2010.
[12] A. Knopfmacher, N. Robbins, On binary and Fibonacci compositions, Ann. Univ. Sci. Budapest.Sect. Comput. 22 (2003) 193–206.