1 Introduction

A restricted growth word \(w=w_1w_2\cdots w_n\) is a word over the set of non-negative integers such that \(w_1=\texttt {0}\) and \(0\le w_i\le \texttt {st}(w_1\cdots w_{i-1})+1\), where st is an integer statistic. These words have been widely studied in the literature since they simultaneously generalize several classes of combinatorial objects as restricted growth functions [11, 14], staircase words [16], ascent sequences [5, 9], and Catalan words [1].

In this paper, we focus on Catalan words which are obtained whenever \(\texttt {st}(w)\) returns the last symbol of w. More formally, a word \(w=w_1w_2\cdots w_n\) is a Catalan word if

$$\begin{aligned} w_1=\texttt {0}~ \text{ and } ~ 0\le w_i\le w_{i-1}+1 ~ \text{ for } ~i=2, \dots , n. \end{aligned}$$

For \(n\ge 0\), let \({\mathcal {C}}_n\) denote the set of Catalan words of length n (the Catalan word of length 0 is the empty word \(\epsilon \)). For example, we have

$$\begin{aligned} {\mathcal {C}}_4&=\{ \texttt {0000}, \texttt {0001}, \texttt {0010}, \texttt {0011}, \texttt {0012}, \texttt {0100}, \texttt {0101}, \\&\qquad \texttt {0110}, \texttt {0111}, \texttt {0112}, \texttt {0120}, \texttt {0121}, \texttt {0122}, \texttt {0123}\}. \end{aligned}$$

The cardinality of the set \({\mathcal {C}}_n\) is given by the Catalan number \(c(n)=\frac{1}{n+1}\left( {\begin{array}{c}2n\\ n\end{array}}\right) \), see [17, Exercise 80]. Catalan words have already been studied in the context of exhaustive generation of Gray codes for growth-restricted words [11, 14]. More recently, Baril et al. [1, 2] study the distribution of descents on restricted Catalan words avoiding a pattern or a pair of patterns of length at most three. Ramírez and Rojas [13] also study the distribution of descents for Catalan words avoiding consecutive patterns of length at most three. Baril and Ramírez [3] give enumerative results for Catalan words avoiding a given pair of relations with respect to the length and the number of descents. Additionally, in [6, 10], the authors started a study of combinatorial statistics on the polyominoes associated with words in \({\mathcal {C}}_n\).

The goal of this work is to complement all these studies by providing enumerative results for Catalan words avoiding a pattern of length at most three with respect to the length and the last symbol. Using classical methods presented in [8, 12], we also give the exact value or an asymptotic approximation for the expectation of the last symbol for these words. Notice that this work is, in a way, a counterpart for Catalan words of the study of Bernini et al. [4] which enumerate permutations avoiding generalized patterns with respect to the last symbol.

The remaining of this paper is structured as follows. In Sect. 2, we give some definitions and notations about pattern avoidance and generating functions. As a preliminary result, we yield the bivariate generating function that counts the number of Catalan words (without avoidance of a pattern), with respect to the length and the last symbol, and we deduce the expectation (i.e. the average) of the last symbol on all length n Catalan words. In Sect. 3, we make a similar study for Catalan words avoiding a pattern of length 2. In Sect. 4, we focus on the avoidance of patterns p of length three, and we give asymptotic approximations (see [8, 12]) for the expectation of the last symbol. Finally, in Sect. 5 we show how we can obtain recurrence relations and asymptotic approximations for the coefficients of generating functions and for the expectations of the last symbol, by using Mathematica and Maple libraries.

2 Notations and Preliminaries

For an integer \(r\ge 2\), a pattern \(p=p_1p_2\cdots p_r\) is a word (of length r) over the set \(\{ 0, 1, \dots , r-1\}\) satisfying the condition: if \(j>0\) appears in p, then \(j-1\) also appears in p. For instance, there are three patterns of length two (00, 01, 10), and thirteen patterns of length three (000, 001, 010, 011, 012, 021, 100, 101, 102, 110, 120, 201, 210). A Catalan word \(w=w_1w_2\cdots w_n\) contains the pattern \(p=p_1p_2\cdots p_r\) if there exists a subsequence \(w_{i_1}w_{i_2}\cdots w_{i_r}\) of w (\(i_1<i_2<\cdots <i_r\)) which is order-isomorphic to p. We say that w avoids p whenever w does not contain the pattern p. For example, the Catalan word \(\texttt {0123455543}\) avoids the pattern 001 and contains three subsequences isomorphic to the pattern 210.

For \(n\ge 0\), let \({\mathcal {C}}_n(p)\) denote the set of Catalan words of length n avoiding the pattern p. We denote by \(\varvec{c}_{p}(n)\) the cardinality of \({\mathcal {C}}_n(p)\), \({\mathcal {C}}(p):=\bigcup _{n\ge 0}{\mathcal {C}}_n(p)\), and \({\mathcal {C}}(p)^+:={\mathcal {C}}(p)\setminus \{\epsilon \}\). We denote by \({\textsf {last}}(w)\) the last symbol of w. Let \({\mathcal {C}}_{n,k}(p)\) denote the set of Catalan words \(w\in {\mathcal {C}}_n(p)\) such that \({\textsf {last}}(w)=\texttt {k}\), and let \(\varvec{c}_{p}(n,k):=|{\mathcal {C}}_{n,k}(p)|\). Obviously, we have \(\varvec{c}_{p}(n)=\sum _{k=0}^{n-1}\varvec{c}_{p}(n,k)\).

We introduce the bivariate generating function

$$\begin{aligned} \varvec{H}_{p}(x,y):=\sum _{w\in {\mathcal {C}}(p)^+}x^{|w|}y^{{\textsf {last}}(w)}=\sum _{n\ge 1, \ k \ge 0}\varvec{c}_{p}(n,k)x^ny^k, \end{aligned}$$

and we set

$$\begin{aligned} \varvec{H}_{p}(x):=\sum _{w\in {\mathcal {C}}(p)^+}x^{|w|}=\varvec{H}_{p}(x,1). \end{aligned}$$

Notice that these generating functions do not consider the empty word. The expectation of the last symbol on all Catalan words in \({\mathcal {C}}_n(p)\) is given by (see [8])

$$\begin{aligned} \varvec{a}_p(n):=\frac{[x^n]\partial _y\varvec{H}_{p}(x,y)|_{y=1}}{\varvec{c}_p(n)}=\frac{[x^n]\partial _y\varvec{H}_{p}(x,y)|_{y=1}}{[x^n]\varvec{H}_{p}(x,1)}. \end{aligned}$$

Moreover, if we omit the subscript p in all previous notations, then this means we refer to the set of all Catalan words of length n (without avoidance of a pattern).

For a Catalan word \(w=w_1w_2\cdots w_n\), \(n\ge 0\), and an integer \(a>0\), we denote by \((w+a)\) the word \((w_1+a)(w_2+a)\cdots (w_n+a)\) obtained from w by increasing by a each of its symbols. In the case where w is the empty word \(\epsilon \), we set \((w+a)=\epsilon \). Using this notation, any non-empty Catalan word has a first return decomposition as follows: \(w=\texttt {0}(w'+1)w''\) where \(w',w''\) are two Catalan words. From this decomposition, a non-empty Catalan word w is either of the three forms (i) \(w=\texttt {0}\), or (ii) \(w=\texttt {0}(w'+1)\) with \(w'\in {\mathcal {C}}^+\), or (iii) \(w=\texttt {0}(w'+1)w''\) with \(w'\in {\mathcal {C}}\) and \(w''\in {\mathcal {C}}^+\). So, we deduce the following functional equation

$$\begin{aligned} \varvec{H}(x,y)=x+xy\varvec{H}(x,y)+x(\varvec{H}(x)+1)\varvec{H}(x,y), \end{aligned}$$

which provides

$$\begin{aligned} \varvec{H}(x,y)=\frac{1 - 2 x y - \sqrt{1 - 4 x}}{2 (1 - y + x y^2)}\quad \text{ and } \quad \varvec{H}(x,1)=\varvec{C}(x), \end{aligned}$$

where \(\varvec{C}(x):=\frac{1-2x-\sqrt{1-4x}}{2 x}\) is the well known generating function for the non-empty Catalan words. Thanks to [6, 18], we obtain

$$\begin{aligned} {[}x^ny^k]\varvec{H}(x,y)= & {} \frac{k + 1}{n}\left( {\begin{array}{c}2 n - 2 - k\\ n-1\end{array}}\right) , \quad n\ge 1, k \ge 0 \text{ and } \\ {[}x^n]\partial _y\varvec{H}(x,y)|_{y=1}= & {} [x^n]\varvec{C}(x)^2=\frac{4}{n+2} \left( {\begin{array}{c}2 n -1\\ n -2\end{array}}\right) . \end{aligned}$$

Then, the expectation of the last symbol of a Catalan word in \({\mathcal {C}}_n\) is

$$\begin{aligned} \varvec{a}(n)=\frac{4 {\left( {\begin{array}{c}2 n -1\\ n -2\end{array}}\right) } \left( n +1\right) }{(n +2){\left( {\begin{array}{c}2 n\\ n\end{array}}\right) }}=\frac{2(n-1)}{n+2}, \end{aligned}$$

and its limit is 2 when \(n\rightarrow \infty \).

3 Avoidance of Length 2 Patterns

In this section, we provide the generating functions \(\varvec{H}_{p}(x,y)\) for all patterns \(p\in \{00,01,10\}\), and we give closed forms for the coefficients of \(x^ny^k\) in their series expansions. So, we deduce the expectation of the last symbol on all Catalan words in \({\mathcal {C}}_{p}(n)\).

Theorem 3.1

We have

$$\begin{aligned} \varvec{H}_{00}(x,y)=\frac{x}{1-xy},\quad \varvec{c}_{00}(n,k)=\left\{ \begin{array}{ll}1,&{} \text{ if } k=n-1\\ 0 ,&{} \text{ otherwise } \end{array} \right. ,\quad \text{ and } \quad \varvec{a}_{00}(n)=n-1. \end{aligned}$$

Proof

The word 012\(\cdots \)n-1 is the unique non-empty word avoiding the pattern 00. \(\square \)

Theorem 3.2

We have

$$\begin{aligned} \varvec{H}_{01}(x,y)=\frac{x}{1-x},\quad \varvec{c}_{01}(n,k)=\left\{ \begin{array}{ll}1,&{} \text{ if } k=0\\ 0,&{} \text{ otherwise } \end{array} \right. ,\quad \text{ and } \quad \varvec{a}_{01}(n)=0. \end{aligned}$$

Proof

The word 00\(\cdots \)0 is the unique non-empty word avoiding the pattern 01. \(\square \)

Theorem 3.3

We have

$$\begin{aligned} \varvec{H}_{10}(x,y)=\frac{x}{1-x(1+y)},\quad \varvec{c}_{10}(n,k)= \left( {\begin{array}{c}n-1\\ k\end{array}}\right) , \quad \text{ and } \quad \varvec{a}_{10}(n)=\frac{n-1}{2}. \end{aligned}$$

Proof

Let w be a word in \({\mathcal {C}}_{n,k}(10)\). If \(n\ge 2\), then the symbol immediately before the last one has two options \(k-1\) or k. Then \(\varvec{c}_{10}(n,k)=\varvec{c}_{10}(n-1,k-1)+\varvec{c}_{10}(n-1,k)\) for \(n\ge 2\) and \(k\ge 1\). Additionally, \(\varvec{c}_{10}(n,0)=1\) for all positive integer n. Therefore, the sequence \(\varvec{c}_{10}(n,k)\) is equal to the binomial coefficient \(\left( {\begin{array}{c}n-1\\ k\end{array}}\right) \) and the generating function can be deduced easily. \(\square \)

4 Avoidance of Length 3 Patterns

In this section, we provide the generating functions \(\varvec{H}_{p}(x,y)\) for all patterns p of length three. We also yield closed forms or recurrence relations for the number \(\varvec{c}_{p}(n,k)\) of Catalan words \(w\in {\mathcal {C}}_{p}(n)\) such that \({\textsf {last}}(w)=k\), and we deduce exact values or asymptotic approximations for the expectation of the last symbol on all Catalan words in \({\mathcal {C}}_{p}(n)\).

4.1 The Pattern 012

Theorem 4.1

We have

$$\begin{aligned} \varvec{H}_{012}(x,y)=\frac{x (1- x + x y)}{1-2x}, \end{aligned}$$

and for \(n\ge 2\),

$$\begin{aligned} \varvec{c}_{012}(n,k)={\left\{ \begin{array}{ll}2^{n-2}, &{} \text { if } k=0, 1\\ 0, &{} \text { otherwise} \end{array}\right. }, \quad \text{ and } \quad \varvec{a}_{012}(n)=\frac{1}{2}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(012)\). From the definition of Catalan word, w must be made up exclusively of \(\texttt {0}\)’s and \(\texttt {1}\)’s, and the first symbol is \(\texttt {0}\). Therefore, the Catalan words avoiding the pattern 012 are given by the regular expression

$$\begin{aligned} \texttt {0} \cup \texttt {0}(\texttt {0} \cup \texttt {1})^*\texttt {0} \cup \texttt {0}(\texttt {0} \cup \texttt {1})^*\texttt {1}. \end{aligned}$$

This regular expression translates to the rational generating function

$$\begin{aligned} \varvec{H}_{012}(x,y)=x + \frac{x^2}{1-2x} + \frac{x^2y}{1-2x} = \frac{x (1- x + x y)}{1-2x}. \end{aligned}$$

The closed formula for the sequence \(\varvec{c}_{012}(n,k)\) is obtained by comparing coefficients. \(\square \)

The series expansion of the generating function \(\varvec{H}_{012}(x,y)\) is

$$\begin{aligned} x + (1 + y) x^2 + (2 + 2 y) x^3 + (\varvec{4 + 4 y}) x^4 + (8 + 8 y) x^5 + (16 + 16 y) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(012)=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0110}\} \text { and } {\mathcal {C}}_{4,1}(012)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}\}. \end{aligned}$$

4.2 The Pattern 001

Theorem 4.2

We have

$$\begin{aligned} \varvec{H}_{001}(x,y)=\frac{x(1-x)}{(1-2x)(1-xy)}, \end{aligned}$$

and for \(n\ge 2\),

$$\begin{aligned} \varvec{c}_{001}(n,k)={\left\{ \begin{array}{ll}2^{n-k-2}, &{} \text { if } k<n-1\\ 1,&{}\text { if } k=n-1\\ 0, &{} \text { otherwise} \end{array}\right. }, \quad \text{ and } \quad \varvec{a}_{001}(n)=1-2^{1-n}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(001)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(001)\). If \(w''=\epsilon \), then the generating function for this case is \(x+ xy\varvec{H}_{001}(x,y)\). If \(w''\) is non empty, then \(w''=\texttt {0}^k\), \(k\ge 1\), and the generating function for this case is \(x\left( \varvec{H}_{001}(x)+1\right) \frac{x}{1-x}\). Adding both cases we have the functional equation

$$\begin{aligned} \varvec{H}_{001}(x,y)=x+xy\varvec{H}_{001}(x,y)+\left( \varvec{H}_{001}(x)+1\right) \frac{x^2}{1-x}. \end{aligned}$$

Since \(\varvec{H}_{001}(x)+1=\frac{1-x}{1-2x}\) (see Theorem 5 in [1]), we obtain the result. Classical methods are used for the extraction of the coefficients of \([x^ny^k]\varvec{H}_{001}(x,y)\) and \([x^n]\partial _y\varvec{H}_{001}(x,y)|_{y=1}\). \(\square \)

The series expansion of the generating function \(\varvec{H}_{001}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + y + y^2) x^3 + (\varvec{4 + 2 y + y^2 + y^3}) x^4 + (8 + 4 y + 2 y^2 + y^3 + y^4) x^5 \\{} & {} \quad + (16 + 8 y + 4 y^2 + 2 y^3 + y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned}&{\mathcal {C}}_{4,0}(001)=\{\texttt {0000}, \texttt {0100}, \texttt {0110}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(001)=\{\texttt {0111}, \texttt {0121}\}, \\&{\mathcal {C}}_{4,2}(001)=\{\texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(001)=\{\texttt {0123}\}. \end{aligned}$$

The array \([x^ny^k]\varvec{H}_{001}(x,y)=\varvec{c}_{001}(n,k)\) corresponds with the array A155038 in [15] which enumerates the set \(\mathcal {P}_{n,k}\) of integer compositions of n with first part k. A constructive bijection \(\psi \) between \({\mathcal {C}}_{n,k}(001)\) and \(\mathcal {P}_{n,k}\) can be defined recursively as follows: if \(n=0\) then \(\psi (\epsilon )=0\); if \(n\ge 1\), we distinguish two cases: if \(w=\texttt {0}(w'+1)\texttt {0}^k, k\ge 1\) then we set \(\psi (w)=1^k\psi (\texttt {0}(w'+1))\), and if \(w=\texttt {0}(w'+1)\) then we set \(\psi (w)=(c_1+1)c_2\cdots c_r\) with \(\psi (w')=c_1c_2\cdots c_r\). For instance, we have \(\psi (012200)=1,1,3,1\).

4.3 The Pattern 010

Notice that a Catalan word w is in set \({\mathcal {C}}_{n,k}(010)\) if and only if w is in the set \({\mathcal {C}}_{n,k}(10)\). Therefore, from Theorem 3.3 we conclude the following result.

Theorem 4.3

We have

$$\begin{aligned} \varvec{H}_{010}(x,y)=\frac{x}{1-x-xy}, \end{aligned}$$

and for \(n\ge 1\), \(0\le k\le n-1\), \(\varvec{c}_{010}(n,k)=\left( {\begin{array}{c}n-1\\ k\end{array}}\right) \), and \(\varvec{a}_{010}(n)=(n-1)/2\).

The series expansion of the generating function \(\varvec{H}_{010}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (1 + 2 y + y^2) x^3 + (\varvec{1 + 3 y + 3 y^2 + y^3}) x^4 + (1 + 4 y + 6 y^2 + 4 y^3 + y^4) x^5 \\{} & {} \quad + (1 + 5 y + 10 y^2 + 10 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned}&{\mathcal {C}}_{4,0}(010)=\{\texttt {0000}\}, \quad {\mathcal {C}}_{4,1}(010)=\{\texttt {0001}, \texttt {0011}, \texttt {0111}\}, \\&{\mathcal {C}}_{4,2}(010)=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(001)=\{\texttt {0123}\}. \end{aligned}$$

The array \([x^ny^k]\varvec{H}_{010}(x,y)= \varvec{c}_{010}(n,k)\) corresponds with the Pascal matrix A007318 in [15]. A constructive bijection \(\phi \) between \({\mathcal {C}}_{n,k}(010)\) and the set \(\mathcal {S}_{n-1,k}\) of k-subsets of \(\{1,\ldots ,n-1\}\) can be defined as follows: Let \(w\in {\mathcal {C}}_{n,k}(010)\), we write it \(w=\texttt {0}^{i_0}{} \texttt {1}^{i_1}\cdots \texttt {k}^{i_k}\), with \(i_j\ge 1\), \(0\le j\le k\), and we set \(\phi (w)=\{i_0,i_0+i_1,\ldots , i_0+i_1+\cdots +i_{k-1}\}\). For instance, we have \(\phi (\texttt {011233344})=\{1,3,4,7\}\in \mathcal {S}_{8,4}\).

4.4 The Pattern 021

Theorem 4.4

We have

$$\begin{aligned} \varvec{H}_{021}(x,y)=\frac{x - 5 x^2 + 9 x^3 - 6 x^4 + x^5 (1 - y)}{(1 - 2 x)^2 (1 - x) (1 - x - xy)}. \end{aligned}$$

Moreover, for \(n\ge 2\), \(\varvec{c}_{021}(n,0)=(n-2)\cdot 2^{n-3}+1\), and for \(k\ge 1\),

$$\begin{aligned} \varvec{c}_{021}(n,k)=\sum \limits _{i=k-1}^{n-2}\left( {\begin{array}{c}n-2\\ i\end{array}}\right) , \text{ and } \quad \varvec{a}_{021}(n)=\frac{2^{n-5}(n^2+3n-2)}{(n-1)2^{n-2}+1}\sim \frac{n+4}{8}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(021)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(021)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) where \(w'\) is a possibly empty Catalan word in \({\mathcal {C}}(10)\). From Theorem 3.3 the generating function for this case is

$$\begin{aligned} x+xy\varvec{H}_{10}(x,y)=x + \frac{x^2y}{1-x(1+y)}. \end{aligned}$$

If \(w'=\epsilon \) and \(w''\ne \epsilon \), then the contribution to the generating function is \(x\varvec{H}_{021}(x,y)\). Finally, if \(w'\) and \(w''\) are non empty, then we have two cases.

  • Case 1: \(w'=\texttt {0}^k\) with \(k\ge 1\). Since \(w''\in {\mathcal {C}}(021)\), the generating function is \(x\left( x/(1-x)\right) \varvec{H}_{021}(x,y)\).

  • Case 2: \(w'\in {\mathcal {C}}(10)\setminus {\mathcal {C}}(01) \). In this case \(w''\in {\mathcal {C}}(01)\), that is, \(w''=\texttt {0}^k\) (\(k\ge 1\)). From Theorems 3.3 and 3.2 the generating function for this case is

    $$\begin{aligned} x\left( \varvec{H}_{01}(x)-\varvec{H}_{10}(x)\right) \frac{x}{1-x}=\frac{x^4}{(1-x)^2(1-2x)}. \end{aligned}$$

Therefore, we have the functional equation

$$\begin{aligned} \varvec{H}_{021}(x,y) = x + \frac{x^2y}{1-x(1+y)} + x\varvec{H}_{021}(x,y)+x\frac{x}{1-x}\varvec{H}_{021}(x,y)+\frac{x^4}{(1-x)^2(1-2x)}. \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{021}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{5 + 4 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad + (13 + 8 y + 7 y^2 + 4 y^3 + y^4) x^5 + (33 + 16 y + 15 y^2 + 11 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(021)&=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0110}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(021)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}\}\\ {\mathcal {C}}_{4,2}(021)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(021)=\{\texttt {0123}\}. \end{aligned}$$

Notice that the array \([\varvec{c}_{021}(n,k)]_{n, k \ge 1}\) coincides with the array A055248 in [15].

4.5 The Pattern 102

Theorem 4.5

We have

$$\begin{aligned} \varvec{H}_{102}(x,y)=\frac{x (1 - 4 x + 4 x^2 - x^3(1-y))}{(1 - x) (1 - 3 x) (1 - x(1 + y))}. \end{aligned}$$

Moreover, \(\varvec{c}_{102}(1,0)=1\), and for \(n\ge 2\)

$$\begin{aligned} \varvec{c}_{102}(n,k)= & {} {\left\{ \begin{array}{ll}\sum _{k=0}^{n-2}\varvec{c}_{102}(n-1,k),&{} \text{ if } k=0,1\\ \varvec{c}_{102}(n-1,k-1)+\varvec{c}_{102}(n-1,k),&{} \text{ if } 2\le k\le n-1\\ 0,&{}\text{ otherwise }\end{array}\right. }, \text{ and } \\ \varvec{a}_{102}(n)= & {} \frac{4 \cdot 3^{n -1}-2^{n}}{3^{n -1}+1}\sim 4. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(102)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(102)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\) possibly empty. The generating function for this case is \(x+xy\varvec{H}_{102}(x,y)\). If \(w''\ne \epsilon \), then \(w=\texttt {0}w''\) or \(w=\texttt {0}(w'+1)w''\) with \(w''\in {\mathcal {C}}(012)^+\). Therefore, the contribution to the generating function is

$$\begin{aligned} x\varvec{H}_{102}(x,y) + x\varvec{H}_{102}(x)\varvec{H}_{012}(x,y), \end{aligned}$$

where (see Theorem 8 of [1])

$$\begin{aligned} \varvec{H}_{102}(x)=\frac{1-3x+x^2}{(1-x)(1-3x)}-1. \end{aligned}$$

Therefore, we have the functional equation

$$\begin{aligned} \varvec{H}_{102}(x,y) = x+xy\varvec{H}_{102}(x,y) + x\varvec{H}_{102}(x,y) + x\varvec{H}_{102}(x)\varvec{H}_{012}(x,y). \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{102}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{5 + 5 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad + (14 + 14 y + 8 y^2 + 4 y^3 + y^4) x^5 + (41 + 41 y + 22 y^2 + 12 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(102)&=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0110}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(102)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(102)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(102)=\{\texttt {0123}\}. \end{aligned}$$

The array \([\varvec{c}_{102}(n,k)]_{n, k \ge 0}\) does not appear in [15].

4.6 The Pattern 201

Theorem 4.6

We have

$$\begin{aligned} \varvec{H}_{201}(x,y)= & {} \frac{x (1 - 5 x + 7 x^2 - 2 x^3)}{(1 - x) (1 - 3 x) (1 + x^2 y - x (2 + y))},\\ \varvec{c}_{201}(n,k)= & {} {\left\{ \begin{array}{ll} \frac{3^{n-2}+1}{2},&{} \text{ if } k=0\\ \varvec{c}_{201}(n-1,k-1)+\varvec{c}_{201}(n-1,k)&{}\\ \qquad \qquad +\, \varvec{c}_{201}(n-2,k)+\varvec{c}_{201}(n-2,k+1),&{} \text{ if } 1\le k\le n-1\\ 0,&{} \text{ otherwise }\\ \end{array}\right. }, \text{ and } \\ \varvec{a}_{201}(n)= & {} 2\frac{3^{n-1}-F(2n-2)}{3^{n-1}+1}\sim 2, \end{aligned}$$

where F(n) is the n-th term of the Fibonacci sequence defined by \(F(n)=F(n-1)+F(n-2)\) anchored with \(F(0)=F(1)=1\).

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(201)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(201)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\) possibly empty. The generating function for this case is \(x+xy\varvec{H}_{201}(x,y)\). If \(w''\ne \epsilon \) and \(w'=\epsilon \), then \(w=\texttt {0}w''\) with \(w''\in {\mathcal {C}}(201)\). The contribution to the generating function is \(x\varvec{H}_{201}(x,y)\). If \(w'\) and \(w''\) are non empty, then we have two cases.

  • Case 1: \(w'=\texttt {0}^n\) with \(n\ge 1\). Since \(w''\in {\mathcal {C}}(021)^+\), the generating function is \(x\frac{x}{1-x}\varvec{H}_{201}(x,y)\).

  • Case 2: \(w'\in {\mathcal {C}}(201)^+\setminus \{\texttt {0}^k, k\ge 1\}\). In this case \(w''=\texttt {0}^n\) for \(n\ge 1\). The generating function for this case is

    $$\begin{aligned} x\left( \varvec{H}_{201}(x)-\frac{x}{1-x}\right) \frac{x}{1-x}, \end{aligned}$$

    where (see Theorem 8 of [1])

    $$\begin{aligned} \varvec{H}_{201}(x)=\frac{1-3x+x^2}{(1-x)(1-3x)}-1. \end{aligned}$$

Therefore, we have the functional equation

$$\begin{aligned} \varvec{H}_{201}(x,y)= & {} x+xy\varvec{H}_{201}(x,y) + x\varvec{H}_{201}(x,y)\\{} & {} +x\frac{x}{1-x}\varvec{H}_{201}(x,y) + x\left( \varvec{H}_{201}(x) - \frac{x}{1-x}\right) \frac{x}{1-x}. \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{201}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{5 + 5 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad + (14 + 13 y + 9 y^2 + 4 y^3 + y^4) x^5 + (41 + 35 y + 26 y^2 + 14 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(201)&=\{\texttt {0000}, \texttt {0100}, \texttt {0110}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(201)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(201)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(201)=\{\texttt {0123}\}. \end{aligned}$$

The array \([\varvec{c}_{201}(n,k)]_{n, k \ge 0}\) does not appear in [15].

4.7 The Pattern 120

Theorem 4.7

We have

$$\begin{aligned} \varvec{H}_{120}(x,y)= & {} \frac{(1 - x) x}{1 - x (2 + y) + yx^2},\\ \varvec{c}_{120}(n,k)= & {} {\left\{ \begin{array}{ll} 2^{n-2},&{} \text{ if } k=0\\ \varvec{c}_{120}(n-1,k-1)+\varvec{c}_{120}(n-1,k)&{}\\ \qquad \qquad +\,\varvec{c}_{120}(n-2,k)+\varvec{c}_{120}(n-2,k+1),&{} \text{ if } 1\le k\le n-1\\ 0,&{} \text{ otherwise }\\ \end{array}\right. }, \text{ and }\\ \varvec{a}_{120}(n)= & {} \frac{2(n-1)F(2n-2)-(n-3)F(2n-3)}{5F(2n-2)}\sim \frac{2 n}{5+\sqrt{5}}, \end{aligned}$$

where F(n) is the Fibonacci sequence defined in Theorem 4.6.

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(120)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(120)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\) possibly empty. The generating function for this case is \(x+xy\varvec{H}_{120}(x,y)\). If \(w''\ne \epsilon \), then \(w=\texttt {0}w''\) or \(w=\texttt {0}(w'+1)w''\) with \(w'=\texttt {0}^k\), \(k\ge 1\), and \(w''\in {\mathcal {C}}(120)^+\). Therefore, the contribution to the generating function is

$$\begin{aligned} x\varvec{H}_{120}(x,y) + x\left( \frac{x}{1-x}\right) \varvec{H}_{012}(x,y). \end{aligned}$$

So we deduce the functional equation

$$\begin{aligned} \varvec{H}_{120}(x,y) = x+xy\varvec{H}_{120}(x,y) + x\varvec{H}_{120}(x,y) + x\left( \frac{x}{1-x}\right) \varvec{H}_{012}(x,y). \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{120}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{4 + 5 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad +(8 + 12 y + 9 y^2 + 4 y^3 + y^4) x^5 + (16 + 28 y + 25 y^2 + 14 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(120)&=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0110}\}, \quad {\mathcal {C}}_{4,1}(120)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(120)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(120)=\{\texttt {0123}\}. \end{aligned}$$

Notice that the array \([\varvec{c}_{120}(n,k)]_{n\ge 1, k\ge 0}\) coincides with the array A105306 in [15]. Therefore we have the combinatorial identity

$$\begin{aligned} \varvec{c}_{120}(n,k)=\sum _{i=0}^{n-k-1}\left( {\begin{array}{c}k+1\\ i\end{array}}\right) \left( {\begin{array}{c}n - 1 - i\\ k\end{array}}\right) (-1)^i2^{n - 1 - k - i}. \end{aligned}$$

This array is related to the number of non-decreasing Dyck path of semi-length n with k weakly symmetric peaks [7]. We leave open the question of finding a constructive bijection.

4.8 The Pattern 101

Theorem 4.8

We have

$$\begin{aligned} \varvec{H}_{101}(x,y)= & {} \frac{x (1 - 3 x + 2 x^2)}{(1 - 3 x + x^2) (1 - x (1 + y))},\\ \varvec{c}_{101}(n,k)= & {} {\left\{ \begin{array}{ll} F(2n-4),&{} \text{ if } k=0\\ \varvec{c}_{101}(n-1,k-1)+\varvec{c}_{101}(n-1,k),&{} \text{ if } 1\le k\le n-1\\ 0,&{} \text{ otherwise }\\ \end{array}\right. }, \text{ and }\\ \varvec{a}_{101}(n)= & {} \frac{F(2n-1)-2^{n-1}}{F(2n-2)}\sim \frac{\sqrt{5}+1}{2}, \end{aligned}$$

where F(n) is the Fibonacci sequence defined in Theorem 4.6.

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(101)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(101)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\) possibly empty. The generating function for this case is \(x+xy\varvec{H}_{101}(x,y)\). If \(w''\ne \epsilon \), then \(w=\texttt {0}w''\) or \(w=\texttt {0}(w'+1)\texttt {0}^+\) with \(w'\in {\mathcal {C}}(101)^+\). Therefore, the contribution to the generating function is

$$\begin{aligned} x\varvec{H}_{101}(x,y) + x\varvec{H}_{101}(x)\left( \frac{x}{1-x}\right) , \end{aligned}$$

where (see Theorem 9 of [1])

$$\begin{aligned} \varvec{H}_{101}(x)=\frac{1 - 2 x}{1 - 3 x + x^2}-1. \end{aligned}$$

Therefore, we have the functional equation

$$\begin{aligned} \varvec{H}_{101}(x,y) = x+xy\varvec{H}_{101}(x,y) + x\varvec{H}_{101}(x,y) + x\varvec{H}_{101}(x)\left( \frac{x}{1-x}\right) . \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{101}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{5 + 4 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad + (13 + 9 y + 7 y^2 + 4 y^3 + y^4) x^5 + (34 + 22 y + 16 y^2 + 11 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(101)&=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0110}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(101)=\{\texttt {0001}, \texttt {0011}, \texttt {0111}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(101)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(101)=\{\texttt {0123}\}. \end{aligned}$$

The array \([\varvec{c}_{101}(n,k)]_{n, k \ge 0}\) does not appear in [15].

4.9 The Pattern 011

Theorem 4.9

We have

$$\begin{aligned} \varvec{H}_{011}(x,y)= & {} \frac{x(1 - 2 x + 2 x^2 - x^3 y)}{\left( 1-x\right) ^3 \left( 1-xy \right) },\\ \varvec{c}_{011}(n,k)= & {} {\left\{ \begin{array}{ll} \frac{(n-1)(n-2)}{2},&{} \text{ if } k=0\\ 1,&{} \text{ if } 1\le k\le n-1\\ 0,&{} \text{ otherwise }\\ \end{array}\right. }, \text{ and } \varvec{a}_{011}(n)=1+\frac{2}{n(n-1)}\sim 1. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(011)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(011)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\in {\mathcal {C}}(00)\) (possibly empty). The generating function for this case is \(x+xy\varvec{H}_{00}(x,y)\). If \(w''\ne \epsilon \), then \(w=\texttt {0}w''\) or \(w=\texttt {0}(w'+1)w''\). In the first case \(w''\in {\mathcal {C}}(011)^+\). In the second case, with \(w'\in {\mathcal {C}}(00)\) and \(w''\) is a word of the form \(\texttt {0}^j\texttt {123}\cdots \), for \(j\ge 1\). Therefore, we have the functional equation

$$\begin{aligned} \varvec{H}_{011}(x,y)=x+xy\varvec{H}_{00}(x,y)+x\varvec{H}_{011}(x,y)+ x\varvec{H}_{00}(x) \frac{x}{1-x}. \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{011}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + y + y^2) x^3 + (\varvec{4 + y + y^2 + y^3}) x^4\\{} & {} \quad + (7 + y + y^2 + y^3 + y^4) x^5 + (11 + y + y^2 + y^3 + y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(011)&=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(011)=\{\texttt {0001}\}\\ {\mathcal {C}}_{4,2}(011)&=\{\texttt {0012}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(011)=\{\texttt {0123}\}. \end{aligned}$$

The array \([\varvec{c}_{011}(n,k)]_{n, k \ge 0}\) does not appear in [15].

4.10 The Pattern 000

Theorem 4.10

We have

$$\begin{aligned} \varvec{H}_{000}(x,y)= & {} \frac{x (1 - 3 x^2 - x^3 - (1 - x - 3 x^2 + x^3) x^2y)}{(1 - x - 3 x^2 + x^3) (1 - x y - 2 x^2 y + x^3 y^2)},\\ \varvec{c}_{000}(n,k)= & {} {\left\{ \begin{array}{ll} 1,&{} \text{ if } k=0, ~n=1, 2, 3\\ \varvec{c}_{000}(n-1,k) + 3\varvec{c}_{000}(n-2,k)-\varvec{c}_{000}(n-3,k),&{} \text{ if } k=0,~ n\ge 4\\ \varvec{c}_{000}(n-1,k-1)+2\varvec{c}_{000}(n-2,k-1)&{}\\ \qquad \qquad \qquad \quad -\ \varvec{c}_{000}(n-3,k-2),&{} \text{ if } k\ge 1, ~n\ge 4\\ 0,&{} \text{ otherwise }\\ \end{array}\right. } \text{ and } \\ \varvec{a}_{000}(n)\sim 1. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(000)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(000)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\) possibly empty. The generating function for this case is \(x+xy\varvec{H}_{000}(x,y)\). The second case is when \(w''\ne \epsilon \), then we have the following four cases:

  • \(w=\texttt {00}\). The generating functions for this case is \(x^2\).

  • \(w=\texttt {00}(w'''+1)\), where \(w'''\in {\mathcal {C}}(000)^+\). In this case the generating function is \(x^2y\varvec{H}_{000}(x,y)\).

  • \(w=\texttt {0}(w'+1)\texttt {0}\), where \(w'\in {\mathcal {C}}(000)^+\). The generating function for this case is \(x^2\varvec{H}_{000}(x)\), where (see Theorem 11 of [1])

    $$\begin{aligned} \varvec{H}_{000}(x)=\frac{(1 - 2 x^2)}{1 - x - 3 x^2 + x^3}-1. \end{aligned}$$
  • \(w=\texttt {0}(w'+1)\texttt {0}(w'''+1)\), where \(w', w''\) are words in \({\mathcal {C}}(000)^+\) and the concatenation \(w'w''\) is again a Catalan word of the second case, that is, the generating function of the words \(w'w'''\) is the same of the generating function of the words of the form \(\texttt {0}(w'+1)w''\), where \(w''\) is non-empty. Therefore, the contribution to the generating function is \(T(x,y)=x^2y(x^2+x^2y\varvec{H}_{000}(x,y)+T(x,y))\).

Therefore, we have the functional equation

$$\begin{aligned} \varvec{H}_{000}(x,y) = x+xy\varvec{H}_{000}(x,y) + x^2 + x^2y\varvec{H}_{000}(x,y) + x^2\varvec{H}_{000}(x) + T(x,y). \end{aligned}$$

Solving the system of equations we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{000}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (1 + 2 y + y^2) x^3 + (\varvec{2 + 3 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad + (4 + 4 y + 6 y^2 + 4 y^3 + y^4) x^5 + (9 + 8 y + 9 y^2 + 10 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(000)&=\{\texttt {0110}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(000)=\{\texttt {0011}, \texttt {0101}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(000)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(000)=\{\texttt {0123}\}. \end{aligned}$$

The array \([\varvec{c}_{000}(n,k)]_{n, k \ge 0}\) does not appear in [15].

4.11 The Pattern 100

Theorem 4.11

We have

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(100)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(100)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\) possibly empty. The generating function for this case is \(x+xy\varvec{H}_{100}(x,y)\). Now let us assume that \(w''\ne \epsilon \). Therefore, w contains at least two symbols \(\texttt {0}\). We distinguish two cases: (i) w contains \(k\ge 3\) symbols \(\texttt {0}\), and (ii) w contains exactly two \(\texttt {0}\).

  • Case (i): w is necessarily of the form \(w=\texttt {0}^{k-2}u\) where \(u\in {\mathcal {C}}(100)\) contains exactly two symbols \(\texttt {0}\). Thus, the generating function for this case is

    $$\begin{aligned} A_2(x,y)\cdot \sum _{k\ge 3}x^{k-2}, \end{aligned}$$

    where \(A_2(x,y)\) is the generating function for Catalan words in \({\mathcal {C}}(100)\) having exactly two symbols \(\texttt {0}\).

  • Case (ii): w can be written \(w=\texttt {0}(w'+1)\texttt {0}(w''+1)\) where \(w',w''\in {\mathcal {C}}(100)\).

    • If \(w'=\epsilon \) then the generating function is \(x^2y\varvec{H}_{100}(x,y)\);

    • If \(w''=\epsilon \) then the generating function is \(x^2\varvec{H}_{100}(x)\) where (see [1])

      $$\begin{aligned} \varvec{H}_{100}(x)=\frac{1-2x-x^2+x^3}{1-3x+2x^3}-1 \end{aligned}$$
    • Otherwise, \(w'\) and \(w''\) are non-empty, where the Catalan word \(w'w''\) avoids 100 and contains at least two symbols \(\texttt {0}\), that is \(w'w''=\texttt {0}^{k-2}{} \texttt {0}(u+1)\texttt {0}(v+1)\). So, there are \(k-1\) choices possibles for \(w'\), namely, \(\texttt {0}, \ldots , \texttt {0}^{k-2}\) and \(\texttt {0}^{k-2}{} \texttt {0}(u+1)\). So, the generating function for these words is \(x^2yA_2(x,y)\sum _{k\ge 2}(k-1)x^{k-2}\). So, we obtain

      $$\begin{aligned} A_2(x,y)=x^2y\varvec{H}_{100}(x,y)+x^2\varvec{H}_{100}(x)+x^2yA_2(x,y)\sum _{k\ge 2}(k-1)x^{k-2}. \end{aligned}$$

Combining all these cases, we obtain the functional equations:

$$\begin{aligned} {\left\{ \begin{array}{ll}\varvec{H}_{100}(x,y)=x+xy\varvec{H}_{100}(x,y)+A_2(x,y)\sum _{k\ge 3}x^{k-2}+A_2(x,y)\\ A_2(x,y)=x^2y\varvec{H}_{100}(x,y)+x^2\varvec{H}_{100}(x)+x^2yA_2(x,y)\sum _{k\ge 2}(k-1)x^{k-2}.\end{array}\right. } \end{aligned}$$

A simple calculation provides the result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{100}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{4 + 5 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad + (9 + 12 y + 9 y^2 + 4 y^3 + y^4) x^5 + (22 + 28 y + 25 y^2 + 14 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(100)&=\{\texttt {0000}, \texttt {0010}, \texttt {0110}, \texttt {0100}\}, \quad {\mathcal {C}}_{4,1}(100)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(100)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(100)=\{\texttt {0123}\}. \end{aligned}$$

4.12 The Pattern 110

Theorem 4.12

We have

$$\begin{aligned} \varvec{H}_{110}(x,y)= & {} \frac{x (1 - 2 x + 2 x^2 - x^2 y + x^3 y)}{(1 - x) (1 - 2 x + x^2 - x y + x^3 y^2)}.\\{} & {} \varvec{a}_{110}(n)\sim \frac{4 \sqrt{2}-5}{4 \sqrt{2}-4}\cdot n\sim 0.3964466089\cdot n. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(110)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(110)\). If \(w''=\epsilon \), then \(w=\texttt {0}(w'+1)\) with \(w'\) possibly empty. The generating function for this case is \(x+xy\varvec{H}_{110}(x,y)\). If \(w''\ne \epsilon \) and \(w'=\epsilon \), then \(w=\texttt {0}w''\). The contribution is \(x\varvec{H}_{110}(x,y)\). If \(w=0(w'+1)w''\) with \(w'\) and \(w''\) non-empty, then \(w'=\texttt {01}\cdots \texttt {k}\) with \(k\ge 0\), and \(w''\) is of the form either \(w''=\texttt {0}^{i_1}{} \texttt {1}^{i_2}\cdots \ell ^{i_\ell }\) with \(0\le \ell \), \(i_j\ge 1\), that is \(w''\in {\mathcal {C}}(10)^+\), or \(w''=\texttt {0}^{i_1}{} \texttt {1}^{i_2}\cdots \texttt {k}^{i_k}(w'''+1)\) with \(i_j\ge 1\) and \(w'''\in {\mathcal {C}}(110)\setminus {\mathcal {C}}(10)\). The contribution for these two cases are respectively \(\frac{x}{1-x}\varvec{H}_{10}(x,y)\) and

$$\begin{aligned} x\left( \sum _{k\ge 1}x^k \cdot \left( \frac{x}{1-x}\right) ^ky^k\right) (\varvec{H}_{110}(x,y)-\varvec{H}_{10}(x,y))=\frac{x^3y}{1-x-x^2y}(\varvec{H}_{110}(x,y)-\varvec{H}_{10}(x,y)). \end{aligned}$$

Therefore we have the functional equation

$$\begin{aligned} \varvec{H}_{110}(x,y)= & {} x+xy\varvec{H}_{110}(x,y) +x\varvec{H}_{110}(x,y)+ \frac{x}{1-x}\varvec{H}_{10}(x,y)\\{} & {} +\frac{x^3y}{1-x-x^2y}(\varvec{H}_{110}(x,y)-\varvec{H}_{10}(x,y)). \end{aligned}$$

Solving the system of equations we obtain the desired result. \(\square \)

The series expansion of the generating function \(\varvec{H}_{110}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{4 + 5 y + 3 y^2 + y^3}) x^4\\{} & {} \quad + (7 + 12 y + 9 y^2 + 4 y^3 + y^4) x^5 + (11 + 26 y + 25 y^2 + 14 y^3 + 5 y^4 + y^5) x^6+ O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(110)&=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(110)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(110)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(110)=\{\texttt {0123}\}. \end{aligned}$$

The array \([\varvec{c}_{110}(n,k)]_{n, k \ge 0}\) does not appear in [15]. A recurrence relation for the coefficients \(\varvec{c}_{110}(n,k)\) can be obtained using Mathematica package (see Sect. 5), but the relation is very ugly and too involved. So we do not provide it here.

4.13 The Pattern 210

Theorem 4.13

We have

where

$$\begin{aligned} a=-1-\frac{\sqrt{21}}{3} \sin \left( \frac{1}{3}\arctan \left( \frac{\sqrt{3}}{9}\right) +\frac{\pi }{6}\right) + \sqrt{7}\cos \left( \frac{1}{3}\arctan \left( \frac{\sqrt{3}}{9}\right) +\frac{\pi }{6}\right) . \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(210)\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(210)\). Then, w has one of the following forms:

  • \(w=\texttt {0}(w'+1)\) where \(w'\in {\mathcal {C}}(210)\); the generating function for these words is \(x+xy\varvec{H}_{210}(x,y)\).

  • \(w=\texttt {0}w''\) where \(w''\in {\mathcal {C}}(210)^+\); the generating function for these words is \(x\varvec{H}_{210}(x,y)\).

  • \(w=\texttt {0}(w'+1)w''\) where \(w'\in {\mathcal {C}}(01)^+\) and \(w''\in {\mathcal {C}}(210)^+\); the generating function for these words is \(x\varvec{H}_{01}(x)\varvec{H}_{210}(x,y)\).

  • \(w=\texttt {0}{} \texttt {1}^{a_1}{} \texttt {2}^{a_2}\cdots \texttt {k}^{a_k}w''\) where \(k\ge 2\), \(a_i\ge 1\) for \(1\le i\le k\), and \(w''\in {\mathcal {C}}(10)^+\); the generating function for these words is \(\varvec{H}_{10}(x,y)\sum _{k\ge 2}\frac{x^{k+1}}{(1-x)^k}\).

  • \(w=\texttt {0}{} \texttt {1}^{a_1}{} \texttt {2}^{a_2}\cdots \texttt {k}^{a_k}{} \texttt {0}^{b_0}{} \texttt {1}^{b_1}{} \texttt {2}^{b_2}\cdots \texttt {(k-2)}^{b_{k-2}}(w''+\texttt {k}-\texttt {1})\) where \(k\ge 2\), \(a_i\ge 1\) for \(1\le i\le k\), \(b_i\ge 1\) for \(0\le i\le k-2\), and \(w''\in {\mathcal {C}}(210)\backslash {\mathcal {C}}(10)\); the generating function for these words is

    $$\begin{aligned} \left( \varvec{H}_{210}(x,y)-\varvec{H}_{10}(x,y)\right) \sum _{k\ge 2}\frac{x^{k+1}}{(1-x)^k}\frac{x^{k-1}}{(1-x)^{k-1}}y^{k-1}. \end{aligned}$$

Combining these different cases, we deduce the functional equation:

$$\begin{aligned} \varvec{H}_{210}(x,y)= & {} x+xy\varvec{H}_{210}(x,y)+x\varvec{H}_{210}(x,y)+x\varvec{H}_{01}(x)\varvec{H}_{210}(x,y)\\{} & {} +\varvec{H}_{10}(x,y)\sum _{k\ge 2}\frac{x^{k+1}}{(1-x)^k}+(\varvec{H}_{210}(x,y)-\varvec{H}_{10}(x,y))\sum _{k\ge 2}\frac{x^{2k}}{(1-x)^{2k-1}}y^{k-1}, \end{aligned}$$

which gives the results. \(\square \)

The series expansion of the generating function \(\varvec{H}_{210}(x,y)\) is

$$\begin{aligned}{} & {} x + (1 + y) x^2 + (2 + 2 y + y^2) x^3 + (\varvec{5 + 5 y + 3 y^2 + y^3}) x^4 \\{} & {} \quad +(13 + 14 y + 9 y^2 + 4 y^3 + y^4) x^5 + (33 + 40 y + 28 y^2 + 14 y^3 + 5 y^4 + y^5) x^6 + O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficients in the above series are

$$\begin{aligned} {\mathcal {C}}_{4,0}(210)&=\{\texttt {0000}, \texttt {0010}, \texttt {0100}, \texttt {0110}, \texttt {0120}\}, \quad {\mathcal {C}}_{4,1}(210)=\{\texttt {0001}, \texttt {0011}, \texttt {0101}, \texttt {0111}, \texttt {0121}\}\\ {\mathcal {C}}_{4,2}(210)&=\{\texttt {0012}, \texttt {0112}, \texttt {0122}\}, \,\text { and }\, {\mathcal {C}}_{4,3}(210)=\{\texttt {0123}\}. \end{aligned}$$

5 An Experimental Approach by Using Computer Algebra

In the previous results we give several recurrence relations and asymptotic expansions for the sequences \(\varvec{c}_{p}(n,k)\) and \(\varvec{a}_p(n)\), respectively. To find some of these recurrences, we used the package Guess (written by Manuel Kauers). It is a Mathematica package for guessing multivariate recurrence equations and it is part of the RISCErgoSum bundle, developed by the Research Institute for Symbolic Computation (RISC).

For example, consider the sequence \(\varvec{c}_{000}(n,k)\). In Theorem 4.10 we prove that the generating function \(\varvec{H}_{000}(x,y)\) is rational, then the term \(\varvec{c}_{000}(n,k)\) can be expressed as linear combinations of the previous terms. Once Guess installed in a Mathematica session we find the recurrence relation given in Theorem 4.10 by executing the following commands.

figure a

From this result we guess that for \(n\ge 4\) and \(k\ge 1\)

$$\begin{aligned} \varvec{c}_{000}(n,k)=\varvec{c}_{000}(n-1,k-1) + 2\varvec{c}_{000}(n-2,k-1)-\varvec{c}_{000}(n-3,k-2). \end{aligned}$$

From the generating function it is not difficult to prove the above equation. In order to obtain asymptotic approximations for \(\varvec{a}_p(n)\), we use two methods: if we can extract the coefficients of \([x^n]\partial _y\varvec{H}_{p}(x,y)|_{y=1}\) and \([x^n]\varvec{H}_{p}(x,1) (=\varvec{c}_p(n))\), we do it and we calculate the limit of the quotient; otherwise, we use classical methods from generating functions (see [8, 12]). Notice such a routine is implemented in a Maple function equivalent of the Algolib and gfun libraries (see http://algo.inria.fr/libraries/).