\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{amsmath,amssymb,amsthm,mathtools}
\usepackage{booktabs,array,adjustbox}
\usepackage{microtype}
\usepackage{xcolor}
\usepackage{fvextra}
\usepackage[colorlinks=true,linkcolor={blue!50!black},urlcolor={blue!50!black},citecolor={blue!50!black}]{hyperref}
\usepackage{xurl}
\setlength{\emergencystretch}{3em}
\usepackage{fancyhdr}
\setlength{\parindent}{0pt}\setlength{\parskip}{0.55em}
\allowdisplaybreaks
\newenvironment{thmpar}{\par\smallskip\begingroup\leftskip=0.9em\rightskip=0pt}{\par\endgroup\smallskip}
\providecommand{\R}{\mathbb{R}}\providecommand{\N}{\mathbb{N}}\providecommand{\Z}{\mathbb{Z}}\providecommand{\Q}{\mathbb{Q}}\providecommand{\C}{\mathbb{C}}
\providecommand{\mathscr}{\mathcal}\providecommand{\bm}{\boldsymbol}\providecommand{\Bbb}{\mathbb}
\providecommand{\bigl}{\mathrm{bigl}}
\providecommand{\bigr}{\mathrm{bigr}}
\providecommand{\cap}{\mathrm{cap}}
\providecommand{\cdot}{\mathrm{cdot}}
\providecommand{\dfrac}{\mathrm{dfrac}}
\providecommand{\dots}{\mathrm{dots}}
\providecommand{\ge}{\mathrm{ge}}
\providecommand{\in}{\mathrm{in}}
\providecommand{\infty}{\mathrm{infty}}
\providecommand{\lceil}{\mathrm{lceil}}
\providecommand{\le}{\mathrm{le}}
\providecommand{\log}{\mathrm{log}}
\providecommand{\min}{\mathrm{min}}
\providecommand{\nu}{\mathrm{nu}}
\providecommand{\prod}{\mathrm{prod}}
\providecommand{\qquad}{\mathrm{qquad}}
\providecommand{\quad}{\mathrm{quad}}
\providecommand{\rceil}{\mathrm{rceil}}
\providecommand{\sum}{\mathrm{sum}}
\providecommand{\theta}{\mathrm{theta}}
\providecommand{\to}{\mathrm{to}}
\pagestyle{fancy}\fancyhf{}\renewcommand{\headrulewidth}{0pt}
\fancyfoot[L]{\footnotesize\begin{tabular}[b]{@{}l@{}}iis:2612.00869 \textperiodcentered{} \href{https://isitsolved.com/journal/80315a60b844}{isitsolved.com/journal/80315a60b844}\\ Timestamped in Bitcoin block 978,729, transaction \href{https://mempool.space/tx/4e0d1472adba2b6f210b8f4fd43a0828a8452842cadb1d4fa7344de919d3a5bb}{\texttt{4e0d1472adba2b6f\ldots{}19d3a5bb}}\end{tabular}}\fancyfoot[R]{\footnotesize\thepage}
\hypersetup{pdftitle={Stanley's coefficient-count generating function is not always rational: a counterexample with powers of 2 and 3},pdfauthor={Dev Singh}}
\title{\bfseries Stanley's coefficient-count generating function is not always rational: a counterexample with powers of 2 and 3}
\author{Dev Singh}
\date{2026-12-04 \\ \small iis:2612.00869}
\begin{document}
\maketitle
\thispagestyle{fancy}
\begin{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 pro\(d_{i\ensuremath{\le}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-2\(x^{2}\)) + \(x^{2}\)/(1-3\(x^{2}\)) is rational. Then nu\_1(2I) = 2\textasciicircum{}(I+1-j0), where j0 is the least j with \(3^{j}\) \ensuremath{\ge} 2\textasciicircum{}(I+1) - 1: the product factors as (1 + x + ... + x\textasciicircum{}(\(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 \ensuremath{\le} 12. Not treated: k \ensuremath{\ge} 2, the more general products, or a characterisation of the G for which rationality holds.
\end{abstract}


\section*{A conjectured rational generating function is not always rational}

\textbf{Result.} The answer is no: for \(G=(1,\allowbreak 1,\allowbreak 2,\allowbreak 3,\allowbreak 4,\allowbreak 9,\allowbreak 8,\allowbreak 27,\allowbreak \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 \href{https://mathoverflow.net/questions/431075}{MathOverflow question 431075}
(Richard Stanley, 2022, no answers).

\begin{thmpar}\textbf{Question.} Let \(G_1,\allowbreak G_2,\allowbreak \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
\href{https://mathoverflow.net/questions/430741}{430741}.)\end{thmpar}

\textbf{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:

\begin{thmpar}\textbf{Theorem.} For \(I\ge 1\),\end{thmpar}


\[\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,\allowbreak \dots,\allowbreak 12\) are \(2,\allowbreak 2,\allowbreak 2,\allowbreak 2,\allowbreak 4,\allowbreak 4,\allowbreak 4,\allowbreak 8,\allowbreak 8,\allowbreak 16,\allowbreak 16,\allowbreak 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\).

\section*{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\).

\emph{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\,\allowbreak 1^j\) (exactly \(j\ge1\) ones) is obtained by
replacing that ending with \(1\,\allowbreak 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}\).

\emph{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.

\emph{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.

\begin{itemize}
  \item 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\)).
  \item 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\)).
\end{itemize}

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

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\).

\section*{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. \ensuremath{\blacksquare}

\section*{Remarks}

\begin{itemize}
  \item 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.
  \item 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.
  \item We did not treat \(k\ge 2\) or the more general products
\(\prod(1+x^{G_i}+\dots+x^{rG_i})\).
\end{itemize}

\section*{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,\allowbreak 1,\allowbreak 1,\allowbreak 2,\allowbreak 1,\allowbreak 1,\allowbreak 2,\allowbreak 1,\allowbreak 2,\allowbreak 1,\allowbreak 1\).

\section*{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.

\section*{Sources}
\begin{enumerate}\small
  \item MathOverflow 431075. \url{https://mathoverflow.net/questions/431075}
  \item Companion question 430741. \url{https://mathoverflow.net/questions/430741}
  \item Repository. \url{https://github.com/DevSingh05/math/tree/main/mo-431075}
\end{enumerate}
\end{document}
