# Stanley's coefficient-count generating function is not always rational: a counterexample with powers of 2 and 3

iis:2612.00869 · by devsingh-lab · https://isitsolved.com/journal/80315a60b844

**Abstract.** MathOverflow 431075 (Stanley; IIS-L-27338): for positive integers G_n -> infinity with rational generating function, let nu_k(n) be the number of coefficients of prod_{i<=n} (1 + x^{G_i}) equal to k; is sum nu_k(n) x^n always rational? No. Take G = 1,1,2,3,4,9,8,27,... (powers of 2 and of 3 alternately), whose generating function x/(1-2x^2) + x^2/(1-3x^2) is rational. Then nu_1(2I) = 2^(I+1-j0), where j0 is the least j with 3^j >= 2^(I+1) - 1: the product factors as (1 + x + ... + x^(2^I - 1)) times the indicator series of integers with ternary digits 0/1, so coefficients count such integers in a window of length 2^I, and exactly two windows per cluster contain a single one. If the series were rational, the zero set of nu_1(2I+2) - nu_1(2I) would be eventually periodic by Skolem-Mahler-Lech, but it has density log_3 2, which is irrational. The formula is confirmed by direct expansion for I <= 12. Not treated: k >= 2, the more general products, or a characterisation of the G for which rationality holds.

# A conjectured rational generating function is not always rational

**Result.** The answer is no: for $G=(1,1,2,3,4,9,8,27,\dots)$ the series $\sum_n\nu_1(n)x^n$ is not rational, with an exact formula for $\nu_1(2I)$. Written proof with a direct computational check; not machine-checked in Lean.


An answer to [MathOverflow question 431075](https://mathoverflow.net/questions/431075)
(Richard Stanley, 2022, no answers).

**Question.** Let $G_1,G_2,\dots$ be positive integers with $G_n\to\infty$ and
$\sum_n G_nx^n$ a rational function. Put $P_n(x)=\prod_{i=1}^n(1+x^{G_i})$ and let
$\nu_k(n)$ be the number of coefficients of $P_n$ equal to $k$. Is
$F(x)=\sum_n\nu_k(n)x^n$ always rational? (For Fibonacci numbers $\nu_k(n)$ is eventually
linear in $n$, by answers to the companion question
[430741](https://mathoverflow.net/questions/430741).)

**Answer: no.** Take powers of 2 and powers of 3 alternately,

$$G=(1,1,2,3,4,9,8,27,16,81,\dots),\qquad G_{2i+1}=2^i,\quad G_{2i+2}=3^i\quad(i\ge 0).$$

Then $G_n\to\infty$ and $\sum_n G_nx^n=\dfrac{x}{1-2x^2}+\dfrac{x^2}{1-3x^2}$ is rational, but
$\sum_n\nu_1(n)x^n$ is not. Precisely:

**Theorem.** For $I\ge 1$,

$$\nu_1(2I)=2^{\,I+1-j_0(I)},\qquad j_0(I)=\min\{j:\ 3^j\ge 2^{I+1}-1\}\quad(=\lceil (I+1)\log_3 2\rceil\ \text{for } I\ge 2),$$

and the sequence $\nu_1(n)$ satisfies no linear recurrence with constant coefficients.

The values $\nu_1(2I)$ for $I=1,\dots,12$ are $2,2,2,2,4,4,4,8,8,16,16,16$. Each term is
equal to the previous one or twice it, and which of the two happens follows the
non-periodic pattern of $\lceil n\log_3 2\rceil$.

## Proof of the formula

$P_{2I}(x)=A(x)B(x)$ with

$$A(x)=\prod_{i<I}(1+x^{2^i})=1+x+\dots+x^{W-1},\quad W=2^I,\qquad
B(x)=\prod_{i<I}(1+x^{3^i})=\sum_{b\in\mathcal B}x^b,$$

where $\mathcal B$ is the set of integers whose base-3 expansion has $I$ digits, all $0$ or
$1$. So the coefficient of $x^m$ in $P_{2I}$ is

$$c(m)=\#\bigl(\mathcal B\cap[m-W+1,\,m]\bigr),$$

the number of elements of $\mathcal B$ in a window of $W$ consecutive integers ending at $m$.

*Gaps of $\mathcal B$.* The successor of an element ending in digit $0$ is that element
plus 1. The successor of an element ending in $0\,1^j$ (exactly $j\ge1$ ones) is obtained by
replacing that ending with $1\,0^j$, a gap of $3^j-\frac{3^j-1}{2}=\frac{3^j+1}{2}$. So
$\mathcal B$ consists of adjacent pairs $\{b,b+1\}$ ($b$ ending in $0$), and for
$1\le j\le I-1$ there are $2^{I-1-j}$ gaps of size $g_j=\frac{3^j+1}{2}$.

*Clusters.* Let $j_0$ be the least $j$ with $g_j\ge W$, that is $3^j\ge 2^{I+1}-1$; one checks
$1\le j_0\le I$. Cut $\mathcal B$ at every gap of size at least $W$. The number of such gaps
is $\sum_{j=j_0}^{I-1}2^{I-1-j}=2^{I-j_0}-1$, so there are $2^{I-j_0}$ pieces (clusters), each
with at least two elements.

*Windows with exactly one element.* Suppose a window contains exactly one element of
$\mathcal B$. That element belongs to a pair $\{b,b+1\}$, and the window contains only one of
the two.

- If it contains $b$ but not $b+1$, the window ends at $m=b$, and it must miss the element
  before $b$, so the gap before $b$ is at least $W$: $b$ is the first element of a cluster
  (or $b=0$).
- If it contains $b+1$ but not $b$, the window starts at $b+1$, and it must miss the element
  after $b+1$, so the gap after $b+1$ is at least $W$: $b+1$ is the last element of a
  cluster (or the largest element of $\mathcal B$).

Conversely each cluster gives exactly these two windows, and they are different. Hence
$\nu_1(2I)=2\cdot 2^{I-j_0}$. ∎

Since $3^j=2^{I+1}-1$ only for $j=I=1$, for $I\ge2$ the condition is $3^j>2^{I+1}$, so
$j_0(I)=\lceil(I+1)\theta\rceil$ with $\theta=\log_3 2$.

## Proof that $F$ is not rational

Suppose $\sum_n\nu_1(n)x^n$ were rational. Then $\nu_1(n)$ satisfies a linear recurrence for
large $n$, and so does $w_I=\nu_1(2I+2)-\nu_1(2I)$. By the Skolem–Mahler–Lech theorem, the set
$Z=\{I: w_I=0\}$ is a finite set together with finitely many full arithmetic progressions, so
it has a rational density.

By the formula, $w_I=0$ exactly when $j_0(I+1)=j_0(I)+1$, that is (for $I\ge2$) when
$\lceil (I+2)\theta\rceil=\lceil (I+1)\theta\rceil+1$. Among $2\le I\le N$ this happens
$\lceil (N+2)\theta\rceil-\lceil 3\theta\rceil$ times, so $Z$ has density
$\theta=\log_3 2$, which is irrational. Contradiction. ∎

## Remarks

- The same argument should work for other pairs of multiplicatively independent bases in place of 2 and 3
  (with the larger base at least 3, so that the digit set has gaps); we only wrote out this case.
- Stanley also asks for which $G$ the series is rational. This example shows that some
  condition is needed beyond rationality of $\sum G_nx^n$; it does not settle which. A
  natural guess is that a single dominant growth rate is what matters.
- We did not treat $k\ge 2$ or the more general products
  $\prod(1+x^{G_i}+\dots+x^{rG_i})$.

## Check it

    python check.py 12

It expands the products directly and compares $\nu_1(2I)$ with the formula for $I\le 12$
(all agree), and prints the ratio pattern $1,1,1,2,1,1,2,1,2,1,1$.

## Status

The thread has no answers and its two comments do not address this; the registry entry lists
it as unanswered. Written proof with a direct computational check of the formula; no second
reader yet; not formalised in Lean.

Produced with an AI assistant: Claude (Anthropic) found the example and wrote the proof and
the check.

