1 Introduction

Recall that \(\lambda =(\lambda _1, \lambda _2, \ldots , \lambda _r)\) is a partition of n, denoted \(\lambda \vdash n\), if \(\lambda _1 \ge \lambda _2 \ge \cdots \ge \lambda _r>0\) are positive integers with \(\sum _{i=1}^{r}\lambda _i=n\). To \(\lambda \) we associate its Young diagram \([\lambda ]\). It is well-known that we can encode partitions by infinite binary sequences, unbounded in each direction, which begin with infinitely many zeros and end with infinitely many ones, see for example [7, Exercise 7.59] or [1]. This encoding can be used, for example, to prove the important fact in representation theory of the symmetric group that the p-core of a partition is unique. To encode a partition \(\lambda \), draw the Young diagram of \(\lambda \) with the left hand vertical edge and upper horizontal edge extended to infinity. Label the southeast boundary of the diagram, including the horizontal and vertical rays, with a zero next to each vertical edge and a one next to each horizontal edge. To obtain the corresponding binary sequence \(C_\lambda \), simply read the numbers moving from southwest to northeast. For example in Fig. 1 we see that if \(\lambda =(5,5,3,3,1)\) then \(C_\lambda =\cdots 00101100110011\ldots .\)

Fig. 1
figure 1

The coding \(C_\lambda \) of the partition \(\lambda =(5,5,3,3,1)\)

After the infinitely many zeros, \(C_\lambda \) has an initial one, corresponding to the first rightward move, and a final zero, corresponding to the last upwards move, before the infinite sequence of ones.

Definition 1.1

Define \(B(\lambda )\) to be the finite binary sequence between the initial one and final zero in \(C_\lambda \). So in Fig. 1, we see that \(B(5,5,3,1)=01100110\), labelled in red.

Of course one can easily recover \(\lambda \) from \(B(\lambda )\). Given a binary sequence C we denote the corresponding partition by P(C), so \(\lambda =P(B(\lambda ))\). Notice that the partition \(\tau =(1)\) corresponds to the empty sequence \(B(\tau )=\emptyset \), so \(P(\emptyset )=(1)\). There is no binary sequence corresponding to the “empty partition.”

Suppose we have a sequence C with A zeros and B ones. It is clear from Fig. 1, that \(B+1\) is the first part of P(C) and \(A+1\) is the number of nonzero parts of P(C).

There are two natural operations on these binary sequences. The reverse sequence just reverses the order in the sequence, and we denote it by \(C^r\). The inverse of a sequence is obtained by switching zeros and ones, and is denoted \(\overline{C}\).

Remark 1.2

There is an equivalent way to define \(B(\lambda )\) in terms of operations on the Young diagram. Start with the Young diagram of \(\lambda \). If \([\lambda ]\) has a single box in the last row (i.e. if the last part is equal to 1), then remove it and record a “0”. If not, then remove the entire first column from the Young diagram (i.e. subtract one from every part), and record a “1”. Continue until only one box remains. The sequence you obtain will be \(B(\lambda )\).

Reversing \(B(\lambda )\) has a nice geometric description in terms of Young diagrams:

Proposition 1.3

Let \(\lambda \), \(B(\lambda )\), A and B be as above. Consider the boxes not in the first row or column as a partition \(\tilde{\lambda }\) sitting inside an \(A \times B\) rectangle. Replace \(\tilde{\lambda }\) with the partition obtained by taking its complement inside the \(A \times B\) rectangle and rotating it 180 degrees, while preserving the first row and column of \(\lambda \). What remains will be the Young diagram for \(P(B(\lambda )^r)\).

Proof

This is clear from Fig. 2. When we rotate the rectangle by 180 degrees, vertical edges remain vertical, horizontal edges remain horizontal. So we can simply rotate all the labels (in red) and the new partition will be correctly labelled with binary sequence equal to \(B(\lambda )^r\). \(\square \)

Example 1.4

Consider the sequence 010100. Check that for \(\lambda =(3,3,3,2,1)\) we have \(B(\lambda )=010100\). Following the algorithm in Proposition 1.3, we see that the partition (3, 3, 2, 1, 1) corresponds to the reverse sequence 001010. This is illustrated in Fig. 2. Notice that n is not typically preserved by this operation.

Fig. 2
figure 2

Calculating the partition corresponding to the reverse sequence

2 The Calkin–Wilf tree

We are going to be studying properties of the sequence \(B(\lambda )\), and in particular when it is a palindrome. This question was motivated by work of [5] on binary sequences and the Calkin–Wilf tree. This is an infinite perfect binary tree with each vertex labelled by a rational number. One can also label this tree by binary sequences in a natural way, and also by Young diagrams of partitions. We give a quick description in this section as motivation, but it is not necessary to understand our results.

The Calkin–Wilf tree, \(T_\mathbb {Q}\), and corresponding Calkin–Wilf sequence, is defined in [2], although it has appeared also much earlier. It is an infinite binary tree with each vertex labelled by a positive rational number written in lowest terms. It is defined inductively as follows. The root is \(\frac{1}{1}\). The left child of \(\frac{p}{q}\) is \(\frac{p}{p+q}\) and the right child is \(\frac{p+q}{q}\). Part of the tree is shown on the right side of Fig. 3. It is not difficult to prove that every positive rational number appears exactly once, and that if \(\frac{p}{q}\) is a reduced fraction, then so are both of its children. To obtain the Calkin–Wilf sequence, read left to right top to bottom, obtaining \(\{1, \frac{1}{2}, \frac{2}{1}, \frac{1}{3}, \frac{3}{2}, \frac{2}{3}, \frac{3}{1}, \ldots \}\). Let l(n) be the n-th term in the Calkin-Wilkin sequence. In [4], the author gives a method to calculate l(n) without generating the entire tree above it. In the opposite direction, in [3] the author gives a method to start with a positive rational number and locate its position in the sequence, and hence on the tree. One first computes the simple continued fraction expansion of the rational number, and then uses it to read off the binary sequence. For example starting with \(\frac{9}{7}\), one obtains:

$$\frac{9}{7}={1}+\frac{1}{{3}+\frac{1}{{2}}}.$$

The sequence \(\{2,3,1\}\) encodes two “1”s, three “0”s, one “1”, thus the binary sequence 110001.

In Fig. 3 we give, on the left, the infinite binary tree labeled by binary sequences starting with 1. So the root is labelled 1, the left child corresponds to appending a zero and the right child to appending a one to the end of the sequence.

Fig. 3
figure 3

The binary tree and Calkin–Wilf tree

Ignoring the initial 1 on each label, we have a bijection between binary sequences of length n and entries in the tree at level \(n+1\). For example the binary sequence 001 corresponds to the fraction 4/3, as labelled in red.

In [5], Kenyon studies the correspondence between binary sequences and rational numbers illustrated in Fig. 3. She calls the sequences “paths,” as they encode the path from the root vertex to the vertex in question, with zero representing left and one representing right. Again note that she does not consider the initial one as part of the path, the rational number \(\frac{1}{1}\) corresponds to an empty path.

It is an easy exercise that the inverse paths (sequences) correspond to reciprocal fractions. It is not at all clear what reversing the path does to the corresponding rational numbers.

Kenyon gathers data on paths that are equal to their reverse, called palindromic paths, and those whose reverse path is equal to the inverse path, called antipalindromic paths. So, for example, 0110 is a palindromic path and corresponds to the rational number 5/7. The path 0101 is an antipalindromic path, corresponding to the rational number 8/5.

We emphasize that the tree on the left of Fig. 3 is labelled in a way to match the previous literature, but the reader should keep in mind when we discuss paths, palindromic paths, etc. that the initial one is not included.

2.1 Partitions in the Calkin–Wilf tree

From Remark 1.2 we see there is a natural way to place Young diagrams at the nodes of a binary tree. Start with the partition \(\lambda =(1)\) at the root. For any partition \(\mu =(\mu _1, \mu _2, \ldots , \mu _t),\) let its left child be \((\mu _1, \mu _2, \ldots , \mu _t,1)\) and its right child be \((\mu _1+1, \mu _2+1, \ldots , \mu _t+1)\). Then following the unique path from a diagram upward to the root will correspond to the operation described in Remark 1.2. This is illustrated in Fig. 4

Fig. 4
figure 4

Partitions on the Calkin–Wilf tree

Remark 2.1

For the Young diagrams in Fig. 4, the diagram \([\lambda ]\) occupies the same spot as the binary sequence which is \(B(\lambda )^r\). This is because we defined \(B(\lambda )\) reading from southwest to northeast to match the existing literature. For example if \(\lambda =(2,2,2)\) we see that \(B(\lambda )=100\) but \(\lambda \) occupies the same position as 001 in the tree. The choice of zero or one for vertical/horizontal moves is arbitrary, as is the choice of which direction to read the sequence off, but the results are all comparable independent of these choices.

For a partition \(\lambda \vdash n\), recall the conjugate or transpose partition \(\lambda ' \vdash n\) can be obtained by swapping rows and columns in the Young diagram. For a box (ij) in the Young diagram, the (ij) hook length is defined as \(\lambda _i -i +\lambda '_j-j+1\).

Proposition 2.2

  1. (1)

    Let \(\lambda \vdash n\). Then \(B(\lambda ')=\overline{B(\lambda )^r}\) is the inverse of the reverse of \(B(\lambda )\). Thus, antipalindromic paths correspond to self-conjugate partitions \(\lambda =\lambda '\).

  2. (2)

    Given \(\lambda \) and \(B(\lambda )\), to find the partition \(P(B(\lambda )^r)\) corresponding to the reverse sequence of \(B(\lambda )\) one can use the algorithm described in Proposition 1.3.

  3. (3)

    Row t of Fig. 4 contains all partitions with first column hook length \(h_{11}(\lambda )=t\). This value is also sometimes called the perimeter of the partition.

Remark 2.3

From Proposition 2.2 we see that we have an action of the Klein four group on the diagram in Fig. 4. The operations come from the the operations of inverse (I) and reversal (R) on the corresponding sequences. We have seen that R fixes the first row and column while replacing the rest with its complement inside a rectangle, whereas \(R\circ I=I \circ R\) takes the transpose of the partition. Thus I does both operations, taking the transpose and then performing the complement operation.

3 Palindrome partitions

Say a partition \(\lambda \vdash n\) is a palindrome partition if the sequence \(B(\lambda )\) is a palindrome, i.e. \(B(\lambda )=B(\lambda )^r\). For example in Fig. 1, we see that \(B(55331)=01100110\), so (5, 5, 3, 1) is a palindrome partition. Define PP(n) to be the number of palindrome partitions of n. Observe that the partitions (n) and \((1^n)\) are palindromes, corresponding to the sequences of all ones and all zeros respectively, so for \(n>1\) we have \(PP(n) \ge 2\). Table 1 gives the sequence PP(n) up to \(n=40\). After this paper appeared in preprint form, this sequence was added to the Online Encyclopedia of Integer Sequences [6] as A368548. The values of \(n+1\) where \(PP(n)=2\) already suggests something interesting is happening!

Table 1 Count of palindrome partitions

We will use the description in Proposition 1.3 to compute a generating function \(\sum _{n=0}^\infty PP(n)q^n\) for PP(n). We will sum over all possible choices for \(\lambda _1\) and \(\lambda '_1\). Let “Case 1” be when both both \(\lambda _1\) and \(\lambda '_1\) are odd, so A and B are both even. Let \(A=2k\) and \(B=2l\). We must count partitions \(\mu \) in the \(2k \times 2l\) rectangle so that \(\mu \) is equal to its complement inside the rectangle. Dividing the large rectangle into 4 rectangles of size \(k \times l\), it is clear that the upper left rectangle must be included in \(\mu \) and the lower right rectangle must be empty. We can select an arbitrary partition \(\tau \) for lower left rectangle, and then its complement in the \(k \times l\) rectangle for the upper right, as shown on the left side of Fig. 5. We have \(\mu \) occupying 2kl boxes. It is well known that there are \(\left( {\begin{array}{c}k+l\\ k\end{array}}\right) \) choices for \(\tau \) fitting inside a \(k \times l\) rectangle. We also have \(2k+2l+1\) boxes in the first row and column. Summing over all possible k and l we have a contribution to the generating function of:

$$\begin{aligned} \sum _{k=0}^{\infty }\sum _{l=0}^{\infty }\left( {\begin{array}{c}k+l\\ k\end{array}}\right) q^{2kl+2k+2l+1}. \end{aligned}$$
(3.1)

Now suppose \(\lambda _1\) is odd and \(\lambda '_1\) is even, call this “Case 2a.” So we are considering \(\mu \) inside a \(2k+1 \times 2l\) box as shown on the right side of Fig. 5. It is clear that the shaded \(1 \times l\) rectangle must be entirely included in \(\mu \). If it were not, there would be a shaded box in the \(1 \times l\) rectangle to its right with an unshaded box to its left, and \(\mu \) would not be a valid palindrome partition. So in this case we have \(\mu \) filling up \((2k+1)l\) boxes, \(\left( {\begin{array}{c}k+l\\ k\end{array}}\right) \) choices for \(\tau \) and \(2k+2l+2\) boxes in the first row and column. Summing over all possible k and l we have a contribution to the generating function of:

$$\begin{aligned} \sum _{k=0}^{\infty }\sum _{l=0}^{\infty }\left( {\begin{array}{c}k+l\\ k\end{array}}\right) q^{2kl+2k+3l+2}. \end{aligned}$$
(3.2)

Now “Case 2b” is when \(\lambda _1\) is even and \(\lambda '_1\) is odd. This would simply give the transpose of the diagram on the right of Fig. 5, and gives another contribution equal to (3.2), as the sum is symmetric in k and l.

There is no “Case 3” where both \(\lambda _1\) and \(\lambda '_1\) are even, as there can be no palindrome partitions as \(\mu \) would need to fill half of the boxes in an odd by odd rectangle. The three cases are summarized in Table 2.

Table 2 Possible parities for \(\lambda _1\) and \(\lambda '_1\)

Thus we have proven:

Theorem 3.1

We have the following generating function:

$$\sum _{n=0}^{\infty }PP(n)q^n=\sum _{k=0}^{\infty }\sum _{l=0}^{\infty }\left( {\begin{array}{c}k+l\\ k\end{array}}\right) q^{2kl+2k+2l+1} + 2\sum _{k=0}^{\infty }\sum _{l=0}^{\infty }\left( {\begin{array}{c}k+l\\ k\end{array}}\right) q^{2kl+2k+3l+2}.$$
Fig. 5
figure 5

Counting palindrome partitions

We are grateful to James Sellers for pointing out a simplification to the generating function in Theorem 3.1 using the binomial series \(\frac{1}{(1-x)^{n+1}} = \sum _{j=0}^{\infty } \left( {\begin{array}{c}n+j\\ j\end{array}}\right) x^j\). In the first double sum we can pull out a \(q^{2k+1}\) term and set \(x=q^{2k+2}\). In the second, we pull out \(q^{2k+2}\) and set \(x=q^{2k+3}\), to obtain:

Corollary 3.2

$$\begin{aligned}\sum _{n=0}^{\infty }PP(n)q^n= & \sum _{k=0}^{\infty }\left[ \frac{q^{2k+1}}{(1-q^{2k+2})^{k+1}} + 2\frac{q^{2k+2}}{(1-q^{2k+3})^{k+1}} \right] \\= & \sum _{k=0}^{\infty } \left[ q^k \Big (\frac{q}{1-q^{2k+2}}\Big )^{k+1} + 2\Big (\frac{q^{2}}{1-q^{2k+3}}\Big )^{k+1}\right] . \end{aligned}$$

In Table 2 we added a fourth column showing the factorization of \(2(n+1)\). We can now use this to explain why \(PP(n)=2\) occurs only when \(n=3\) or \(n+1\) is prime.

Theorem 3.3

The number \(PP(n)=2\) if and only if \(n=3\) or \(n+1>2\) is prime.

Proof

Consider the factorizations of \(n+1\) in Table 2. If \(n+1\) is prime, we are either in Case 2a with \(l=0\) or Case 2b with \(k=0\), corresponding to the partitions \((1^n)\) and (n) respectively. In this case there are no other palindrome partitions. Now suppose \(n+1\) is not prime, so let \(n+1=xy\) with \(x, y>1\). We will explain how to find additional palindrome partitions of n.

If \(n+1\) is odd, then so are x and y. We can find \(\lambda \) in Case 2a with \(l=x-1\ge 2\) and \(k=(y-3)/2\ge 0\). Then any of the \(\left( {\begin{array}{c}k+l+1\\ k\end{array}}\right) \) choices for \(\tau \) will produce a palindrome partition \(\lambda \vdash n\) not equal to (n) or \((1^n)\). A corresponding choice in Case 2b will give the conjugate \(\lambda '\). In the smallest example where \(x=y=3\), we can choose \(k=0\), \(l=2\) or \(k=2, l=0\) and we obtain \(\lambda =(5,3)\) and its conjugate (2, 2, 2, 1, 1).

Finally suppose \(n+1=2x\). If \(x>2\) is even, we can choose \(k=1\), \(l=x/2-1\) in Case 1, to obtain a palindrome partition \(\lambda \vdash n\) not equal to (n) or \((1^n)\). If \(x \ge 3\) is odd, we can choose \(l=1\) and \(k=(x-3)/2\) in Case 2a to obtain a palindrome partition \(\lambda \vdash n\) not equal to (n) or \((1^n)\).

This leaves only the special case where \(n+1=4\), where we see that \(n+1\) is not prime but the only palindrome partitions of \(n=3\) are (3) and (1, 1, 1). \(\square \)

Remark 3.4

The sequence of integers n with \(PP(n)=2\), given by \(\{2,3,4,6,10,12,16,18,22,\ldots \}\), is A068499 at oeis.org: “Numbers n such that m! reduced modulo \((n+1)\) is not zero.” Of course this differs in only two terms from the sequence of n with \(n+1\) prime.

4 Generating palindrome partitions of n

We have seen that, given n, there are always two palindrome partitions of n corresponding to sequences \(B(\lambda )\) of length \(n-1\), namely the all zero sequence corresponding to \((1^n)\) and the all one sequence corresponding to (n). If we want to generate all palindrome partitions of n, we need to know what other sequence lengths can occur, and for each length, how many zeros and ones are included. This will specify the first part \(\lambda _1\) and the first column \(\lambda '_1\), and values for k and l. We simply choose all possible \(\mu \) as in the proof of Theorem 3.1, to obtain a list of all palindrome partitions of n.

Table 3 Palindrome partitions of \(n=11\)

Definition 4.1

Let PL(n) be the number of lengths among all sequences \(B(\lambda )\) as \(\lambda \) runs over all palindrome partitions of n. This is also the number of distinct perimeters among all palindrome partitions of n.

So in Table 3, we see that \(PL(11)=3\) corresponding to the lengths 6,7, 10. For a given length m, we have \(m=A+B\), where the sequence has A zeros and B ones. Recall that swapping zeros and ones gives a sequence also corresponding to a palindrome partition of n. We now classify precisely which lengths occur and prove that, for each possible length, the split into zeros and ones is unique (up to swapping zeros and ones).

Theorem 4.2

PL(n) is the number of factorizations \(xy=2(n+1)\) where \(0< x \le y \le n\). This is the sequence A211270 in [6], shifted by one. Moreover, suppose there is a palindrome partition \(\lambda \vdash n\) with \(B(\lambda )\) having length \(m=A+B\) with A zeros and B ones. Then any other palindrome partition \(\mu \vdash n\) with \(B(\mu )\) of length m must have A zeros and B ones or B zeros and A ones.

Proof

Suppose we have a palindrome partition \(\lambda \) of n where \(B(\lambda )\) has length \(m=A+B\) as in Table 2. Thus k and l are determined and we obtain a factorization as desired from the final column.

Conversely, suppose we have such a factorization \(xy=2(n+1)\). We prove there is a unique corresponding length m and decomposition \(m=A+B\). It is the case that we have one odd factor or no odd factor. If one of the factors is odd, say x, then \(x= 2l+3\) and \(y = 2k+2\), as in case 2. Then it follows that \(A = 2k = y-2\) and \(B = 2l = x-3\). If neither factor is odd, then \(x=2l+2\) and \(y = 2k+2\) which is case 1. So \(A=x-2\) and \(B=y-2\), and we have a palindrome partition with \(B(\lambda )\) of length \(A+B\). Suppose that for a factorization of \(2(n+1)\) we have that both x and y are even where \(m = 2k+2l\) and also \(m=2\tilde{k}+2\tilde{l}\) for some \(k,l, \tilde{k}, \tilde{l}\) where \(k \ne \tilde{k}\) and \(l \ne \tilde{l}\). It could be the case that \(k = \tilde{l}\) and \(l = \tilde{k}\), which would be interchanging the zeros and ones. Consider a nontrivial solution where \(k+l = \tilde{k} + \tilde{l}\). Then \(2(n+1) = (2k+2)(2l+2)=(2\tilde{k}+2)(2\tilde{l}+2)\) which simplifies to \(kl=\tilde{k} \tilde{l}\). Then

$$\begin{aligned} kl&= \tilde{k}\tilde{l} \\ kl + l^2&= \tilde{k}\tilde{l} +l^2 \\ l(k+l)&= \tilde{k}\tilde{l} +l^2 \\ l(\tilde{k}+\tilde{l})&= \tilde{k}\tilde{l} +l^2 \\ (l-\tilde{l})(\tilde{k}-l)&= 0. \end{aligned}$$

Thus \(l = \tilde{l}\) or \(\tilde{k} = l\). Now suppose for a factorization of \(2(n+1)\) that x is odd without loss of generality, which would mean \(m = 2k+2l+1\) and \(m=2\tilde{k}+2\tilde{l}+1\) for some \(k,l, \tilde{k}, \tilde{l}\) where \(k \ne \tilde{k}\) and \(l \ne \tilde{l}\). Again, the case that \(k = \tilde{l}\) and \(l = \tilde{k}\), which would be interchanging the zeros and ones. Suppose we have a nontrivial solution where \(k+l = \tilde{k} + \tilde{l}\). Then \(2(n+1) = (2k+2)(2l+3)=(2\tilde{k}+2)(2\tilde{l}+3)\) which simplifies to \(2kl+k=2 \tilde{k} \tilde{l} + \tilde{k}\). Then

$$\begin{aligned} 2kl+k&= 2\tilde{k}\tilde{l} + \tilde{k}\\ 2kl+k-k+2k^2&= 2\tilde{k}\tilde{l}+\tilde{k}-k+2k^2 \\ 2k(l+k)&= 2\tilde{k}\tilde{l}+\tilde{k}-k+2k^2 \\ 2k(\tilde{l}+\tilde{k})&= 2\tilde{k}\tilde{l}+\tilde{k}-k+2k^2 \\ (\tilde{k}-k)(2k-1-2\tilde{l})&= 0. \\ \end{aligned}$$

Thus \(k = \tilde{k}\) or \(2k = 2\tilde{l}+1\). Therefore, it’s the case that for each word length of m, there is a unique number of zeros and ones, up to swapping zeros and ones. \(\square \)

Example 4.3

We demonstrate how to use the results above to efficiently generate all \(PP(29)=60\), palindrome partitions of \(n=29\). There are five relevant factorizations of \(2(n+1)=60\). For each, we can compute klAB as in the proof above, using Table 2. Once we have these, the first row \(\lambda _1\) and column \(\lambda '_1\) are fixed. Then we have \(\left( {\begin{array}{c}k+l\\ l\end{array}}\right) \) choices for the partition \(\tau \) as in Fig. 5. Table 4 shows the results, where the entries in the penultimate column sum to 60 as expected.

Table 4 Generating palindrome partitions of 29

Remark 4.4

In Example 4.3 we generate palindrome partitions of n sorted by divisors of \(2(n+1)\). Chai Wah Wu has used this idea to give an expression for PP(n), which has the flavor of a divisor sum, and can be found in the OEIS entry for PP(n).

5 Partitions with weight fixed by reversal

As we mentioned in Remark 2.3, sequence reversal gives an action of order two on all partitions given by \(\lambda \rightarrow P(B(\lambda )^r)\). The palindrome partitions are fixed by this operation. In this section, we consider partitions where \(\lambda \) and \(P(B(\lambda )^r)\) are both partitions of the same integer. In other words, these partitions remain in the same row of Fig. 4 under this action. Let R(n) be the number of partitions \(\lambda \vdash n\) where \(P(B(\lambda )^r) \vdash n\).

Computing R(n) is similiar to counting PP(n), but in Fig. 5 we no longer have the requirement that the partition be equal to the rotation of its complement. Instead we require that it fill exactly half of the boxes in the \(2k \times 2l\) or \((2k +1) \times 2l\) rectangle. (As with the palindrome case, if the rectangle has an odd number of boxes then there are no partitions to count).

Recall that the q-binomial coefficient \({n \brack k}_q\) is the generating function for partitions that fit inside an \((n-k) \times k\) rectangle, and is called a Gaussian polynomial. The coefficient of \(q^m\) counts partitions of m fitting inside a \((n-k) \times k\) rectangle, so it has leading term \(q^{k(n-k)}\). In place of the binomial coefficients in Theorem 3.1, we will need the coefficient of the middle degree term in this polynomial. There is a nice description of this coefficient in the case either k or \(n-k\) is even, which we prove here.

Definition 5.1

Let T(nk) be the number of nondecreasing sequences of length n, with integer entries in \([-k,k]\), summing to zero.

For example if \(n=5\) and \(k=4\) a possible sequence would be \(\{-4,-2,1,1,4\}\). The array T(nk) is given as sequence A183917 in the OEIS.

Proposition 5.2

The coefficient of \(q^{kl}\) in the Gaussian polynomial \({2k+l \brack l}_q\) is T(lk).

Proof

The coefficient in question counts all partitions of kl which fit inside an \(l \times 2k\) rectangle, i.e. have at most l parts, each less than or equal to 2k. We give a bijection to the sequences counted by T(lk). Given such a partition \(\lambda =(\lambda _1, \lambda _2, \ldots , \lambda _l) \vdash kl\), the corresponding sequence is \(\{\lambda _l-k, \lambda _{l-1}-k, \lambda _{l-2}-k, \ldots , \lambda _1-k\}\). For example the sequence above corresponds to the partition (8, 5, 5, 2, 0) inside the \(5 \times 8\) rectangle. \(\square \)

We can now write the generating function for R(n) as in Theorem 3.1. The first term is from the \(2k \times 2l\) rectangle so we get T(2lk). The second term is the \((2k+1) \times 2l\) rectangle, which has the same count as a \(2l \times (2k+1)\) rectangle, namely \(T(2k+1,l)\). Thus:

Theorem 5.3

We have the following generating function:

$$\sum _{n=0}^{\infty }R(n)q^n=\sum _{k=0}^{\infty }\sum _{l=0}^{\infty }T(2l,k)q^{2kl+2k+2l+1} + 2\sum _{k=0}^{\infty }\sum _{l=0}^{\infty }T(2k+1,l)q^{2kl+2k+3l+2}.$$
Table 5 Partitions with weight fixed by reversal

Of course \(PP(n) \le R(n)\). Comparing Tables 1 and 5, we see the smallest n with \(PP(n)<R(n)\) is \(n=14\), where \(PP(14)=10\) and \(R(14)=14\). The four extra partitions which are not palindromes are \(\lambda =(44222), R(\lambda )=(43331)\) and \(\mu =(5522), R(\mu )=(5441)\).

Remark 5.4

The proof of Theorem 3.3 applies to the more general setting of computing R(n), i.e. \(R(n)=2\) precisely when \(P(n)=2\).

6 Problems

We suggest some problems for future research.

Problem 6.1

Can we write the generating functions in Theorem 3.1 and 5.3 in a more compact form \(\sum f(n)q^n\)? Can we see clearly from the generating function why \(f(n)=2\) when \(n+1\) is prime?

Problem 6.2

The traditional Young’s lattice has all partitions of n in row n with edges corresponding to removing and/or adding a single box. Classically this describes the branching of irreducible representations of the symmetric group. Does Fig. 4 have any representation- theoretic interpretation?

Problem 6.3

Proposition 1.3 gives a quick way to identify palindrome partitions \(\lambda \) without calculating \(B(\lambda )\). Can one do the same for fractions in the Calkin–Wilf tree corresponding to palindrome sequences, i.e. determine if a fraction corresponds to a palindrome without doing the continued fraction expansion? Can we describe what the reversal operation does to fractions?