Writing Mathematics Properly (for the youngest ones)

Writing a paper is part of doing research. This page collects the advice and the reading I give to the students who work under my supervision.

The Mistakes You Should Avoid

Here is a list containing some of the mistakes I often notice in the first paper drafts of young researchers, with pointers to people who have written about each of them at length.

Structure

  1. No real introduction. The introduction should contain background, history, motivation, the statement of your results, and a road map of the paper. It is also where you convince the reader that the paper is worth reading. (Tao, Use the introduction to “sell” the key points of your paper.)
  2. Results stated inaccurately. Claim exactly what you proved, no more and no less. (Tao, Describe the results accurately.)
  3. One long argument instead of lemmas. A proof that runs for pages should be cut into lemmas with clear statements, each proved once and used many times. (Tao, Create lemmas.)
  4. Important statements buried inside proofs. Many readers skip the proofs. Each milestone of the paper deserves its own clearly stated proposition or theorem, placed before the technical details, and anything the rest of the paper depends on must stand on its own in the text. (Tao, Organise the paper.)
  5. Writing up the path of discovery. The reader wants the shortest correct route to the result, not the story of how you found it. (Rogness, Writing tips.)

Mathematics and Logic

  1. Notation introduced on the fly, or notation that changes meaning. Define every symbol before you use it, and use it for one thing only. (Tao, Use good notation; Miller, Notes on Writing Mathematics.)
  2. “It is easy to see”, “clearly”, “obviously”. These words usually cover a gap. If the step is easy, show it in one line; if it is not, prove it. (J. M. Lee, Some Remarks on Writing Mathematical Proofs.)
  3. Quantifiers in the wrong order or left implicit. Say “for every” and “there exists” in words, in the right order, and avoid the ambiguous “any”. (Milne, Tips for authors; J. M. Lee, Some Remarks on Writing Mathematical Proofs.)
  4. Too much detail, or too little. Routine verifications can be summarized; the steps that carry the argument cannot. (Tao, Give appropriate amounts of detail.)

Language

  1. A sentence that starts with a symbol. A symbol has no capital letter, so the reader cannot see where the sentence begins. Put a word in front of it. (Khovanova, Common Mistakes; Knuth, Larrabee, and Roberts, Mathematical Writing.)
  2. Symbols where words belong. Logical symbols such as \(\forall\), \(\exists\) and \(\Rightarrow\) do not belong in prose, and a formula is not a sentence. (Tao, Take advantage of the English language; Conrad, Advice on Mathematical Writing.)
  3. Contractions and abbreviations. “Don’t”, “we’ll” and “WLOG” are for notes, not for a paper. (Higham, Handbook of Writing for the Mathematical Sciences.)
  4. Words used loosely. “So that” is not “such that”, “verify” is not “satisfy”, and “any” can mean “every” or “some”. (Milne, Tips for authors.)
  5. Displayed formulas without punctuation. A displayed equation is part of a sentence and takes the comma or period that the sentence needs. (Knuth, Larrabee, and Roberts, Mathematical Writing; Higham, Handbook of Writing for the Mathematical Sciences.)

Typography and LaTeX

  1. Every equation numbered. Number only the equations you refer to. (Khovanova, Common Mistakes; Knuth, Larrabee, and Roberts, Mathematical Writing.)
  2. Hard-coded numbers. Refer to theorems, equations and sections with \label and \ref, never by typing the number. (Higham, Handbook of Writing for the Mathematical Sciences.)
  3. Typographic details left to chance. Quotation marks, dashes, \ldots versus \cdots, bracket sizes, and multi-letter operators in upright type all have rules; learn them once. (Knuth, Larrabee, and Roberts, Mathematical Writing; K. P. Lee, A Guide to Writing Mathematics; Higham, Handbook of Writing for the Mathematical Sciences.)

References and Acknowledgments

  1. Sloppy references. Cite the published version when there is one, check every name and title, and do not copy a misspelling from someone else’s bibliography. (Milne, Tips for authors.)
  2. No acknowledgments. Thank the people and the programs that helped you. (Khovanova, Common Mistakes; Higham, Handbook of Writing for the Mathematical Sciences.)

Before You Send a Draft

  1. Sending a first draft. Spell-check, proofread, and read the whole paper as a stranger would before anyone else sees it. (Tao, Proofread and double-check your paper before submission and Submit a final draft, not a first draft.)

A Sample Paper

To see these rules at work, look at the following short paper by Hermione Granger, Harry Potter, and Ron Weasley, the same young researchers who wrote the sample Beamer presentation. The magic is fictional, but the mathematics is real: in the spirit of Lagrange’s four-square theorem, the paper studies which elements of the semiring \(\mathbb{N}_0[q]\), whose generator \(q\) is a positive rational number, are sums of squares, and how many squares they need.

Notice that the introduction gives the history and the motivation, states the main result in words before any technical detail, and ends with a road map of the paper; that every definition is followed by an example, and every result is announced by a sentence; that a lemma proved once is used several times; that no step is waved through with “clearly”; and that the paper ends with open questions, acknowledgments, and references in alphabetical order. Of course, the books from the wizarding world in the references are fictional: every reference in your paper must be real, and you must check it yourself (see item 18 above).

Below, the LaTeX source is on the left and the paper is on the right. Scroll each side to read along. You can also download the paper (PDF) and the LaTeX source. The source uses only standard packages and compiles with pdflatex, so you can start your own paper from it.

\documentclass[12pt]{amsart}

% Package Being Used:

\usepackage{amssymb}
\usepackage{bm}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{stmaryrd}
\usepackage{calrsfs}
\usepackage{fancyhdr}
\usepackage{url}
\usepackage[dvipsnames]{xcolor}
\definecolor{wine}{HTML}{750014}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linkcolor=blue, citecolor=red, urlcolor=wine}

% Paper Format and Geometry:
\voffset=-1.4mm
\oddsidemargin=14pt
\evensidemargin=14pt %17
\topmargin=20pt
\headheight=15pt
\textheight=576pt
\textwidth=444pt %435
\parskip=0pt plus 4pt

% Head Labels:
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhead[CE]{\fontsize{9}{11}\selectfont H. GRANGER, H. POTTER, AND R. WEASLEY}
\fancyhead[CO]{\fontsize{9}{11}\selectfont ACCIO SQUARES! SUMS OF SQUARES IN RATIONAL MONOGENIC SEMIDOMAINS}
\fancyhead[LE,RO]{\thepage}

% Theorems-like Format and Numbering:
\newtheorem*{maintheorem*}{Main Theorem}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{prop}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{cor}[theorem]{Corollary}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{examplex}[theorem]{Example}
\newenvironment{example}{\begin{examplex}\pushQED{\qed}\renewcommand{\qedsymbol}{$\blacksquare$}}{\popQED\end{examplex}}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{question}[theorem]{Question}
\numberwithin{equation}{section}

% Personalized Commands:
\newcommand{\nn}{\mathbb{N}}
\newcommand{\qq}{\mathbb{Q}}
\newcommand{\rr}{\mathbb{R}}
\newcommand{\zz}{\mathbb{Z}}
\newcommand{\sos}{\Sigma}
\providecommand\ldb{\llbracket}
\providecommand\rdb{\rrbracket}

\keywords{sums of squares, Lagrange's four-square theorem, Pythagoras number, semidomain, positive semiring, rational monogenic semidomain}

\subjclass[2020]{Primary: 11E25, 16Y60; Secondary: 11P05, 20M13}

\begin{document}
    \mbox{}
    \title{Accio Squares! \\ Sums of Squares in Rational Monogenic Semidomains}

    \author{Hermione Granger}
    \address{Hogwarts School of Witchcraft and Wizardry\\Scottish Highlands, AB 12345}
    \email{hermione@hogwarts.uk}

    \author{Harry Potter}
    \address{Hogwarts School of Witchcraft and Wizardry\\Scottish Highlands, AB 12345}
    \email{hpotter@hogwarts.uk}

    \author{Ron Weasley}
    \address{Hogwarts School of Witchcraft and Wizardry\\Scottish Highlands, AB 12345}
    \email{rweasley@hogwarts.uk}

    \date{\today}


    \begin{abstract}
        Lagrange's four-square theorem states that every nonnegative integer is the sum of four squares of integers. In this paper, we investigate the same question in rational monogenic semidomains, which are the semirings consisting of the values that polynomials with nonnegative integer coefficients take at a fixed positive rational number. We prove that every element of such a semiring is a sum of squares of elements of the same semiring if and only if the fixed rational number or its reciprocal is an integer; in this case, four squares always suffice, and four squares are sometimes needed. In all the remaining cases, we show that there are elements that can be written as sums of squares, but only using as many squares as we wish, which means that the Pythagoras number of the semiring is infinite. Finally, for the rational number two thirds, we describe the elements that are sums of squares, provide an algorithm to decide whether a given element is a sum of squares, and bound the number of squares needed in terms of the denominator of the element.
    \end{abstract}

\maketitle








%%%%%%%%%%%%
%%%%%%%%%%%%
\section{Introduction: Lagrange's Ancient Spell}
\label{sec:intro}

Which positive integers can be written as sums of squares of integers, and how many squares are needed? Questions of this kind are among the oldest in number theory. In his 1621 edition of Diophantus' \emph{Arithmetica}, Bachet conjectured that every positive integer is a sum of four squares of integers, and Lagrange proved this conjecture in 1770. Before that, Fermat had claimed and Euler had proved that an odd prime is a sum of two squares exactly when it leaves remainder~$1$ upon division by~$4$, and around 1800 Legendre and Gauss characterized the positive integers that are sums of three squares. Since $7$ is not a sum of three squares, the number four in Lagrange's theorem cannot be improved. We refer the reader to \cite{HW08,mN96} for proofs of these classical results and for some of their history, and to~\cite{bB47} for their history in the wizarding world.
\smallskip

One can ask the same questions for every commutative ring~$R$: which elements of~$R$ are sums of squares, and is there a positive integer~$n$ such that every sum of squares in~$R$ is a sum of at most $n$ squares? The smallest such $n$, when it exists, is called the \emph{Pythagoras number} of~$R$. For instance, the Pythagoras number of the field of real numbers is~$1$, while the Pythagoras number of the field of rational numbers is~$4$. Pythagoras numbers of fields and rings have been systematically investigated in the literature (see \cite{CDLR82} and the references therein, and see~\cite{sV97} for an arithmantic point of view).
\smallskip

In this paper, we study sums of squares in a class of semirings. A \emph{semidomain} is a subset of an integral domain that contains $0$ and~$1$ and is closed under both addition and multiplication. For instance, the set of nonnegative integers is a semidomain, and so is the set of nonnegative rational numbers. In a semidomain consisting of nonnegative real numbers, every element is a candidate to be a sum of squares, and so it is natural to ask whether every element is a sum of squares, exactly as Lagrange's theorem does for the nonnegative integers. Our main objects of study are the \emph{rational monogenic semidomains}: for a positive rational number~$q$, the rational monogenic semidomain $\nn_0[q]$ is the set of all the values $f(q)$, where $f$ ranges over all polynomials with nonnegative integer coefficients. Equivalently, $\nn_0[q]$ is the smallest semidomain containing~$q$. For instance, $\nn_0[1/2]$ consists of the nonnegative rational numbers whose denominators are powers of~$2$, while $\nn_0[2/3]$ is a more mysterious semidomain: it contains $2/3$ and $4/9$, but it does not contain~$1/3$. The additive and multiplicative structures of rational monogenic semidomains (and of some of their generalizations) have been investigated in recent years from the point of view of factorization theory \cite{ABP21,CGG20,CMG22,GP23}.
\smallskip

Here is the question that motivated this paper: for which positive rational numbers~$q$ is every element of $\nn_0[q]$ a sum of squares of elements of $\nn_0[q]$, and how many squares are needed in this case? An important subtlety is that the square roots must belong to $\nn_0[q]$: just as underage wizards are not allowed to use magic outside Hogwarts, our square roots are not allowed to leave $\nn_0[q]$. For instance, the equality
\[
    \frac23 = \Big( \frac23 \Big)^2 + \Big( \frac13 \Big)^2 + \Big( \frac13 \Big)^2
\]
does not express $2/3$ as a sum of squares in $\nn_0[2/3]$ because $1/3 \notin \nn_0[2/3]$. In fact, we will see that $2/3$ is not a sum of squares in $\nn_0[2/3]$ at all. The main result of this paper is the following theorem, which completely answers our motivating question.

\begin{maintheorem*}
    Let $q = a/b$, where $a$ and $b$ are relatively prime positive integers.
    \begin{enumerate}
        \item If either $a = 1$ or $b = 1$ then every element of $\nn_0[q]$ is a sum of at most four squares of elements of $\nn_0[q]$, and the element~$7$ is not a sum of fewer than four such squares.
        \smallskip

        \item If $a > 1$ and $b > 1$ then $q$ is not a sum of squares of elements of $\nn_0[q]$. Moreover, for each $N \in \nn$, there exists an element of $\nn_0[q]$ that is a sum of $N$ squares of elements of $\nn_0[q]$ but is not a sum of fewer than $N$ such squares.
    \end{enumerate}
\end{maintheorem*}

In terms of Pythagoras numbers, the Main Theorem says that the Pythagoras number of $\nn_0[q]$ is~$4$ when either $a = 1$ or $b = 1$, and it is infinite otherwise. Observe that part~(2) is much stronger than saying that not every element of $\nn_0[q]$ is a sum of squares: it says that even the elements that are sums of squares may need as many squares as we wish.
\smallskip

When $a > 1$ and $b > 1$, it is natural to ask which elements of $\nn_0[q]$ are sums of squares, and how many squares each of them needs. For $q = 2/3$, we completely answer the first question: an element of $\nn_0[2/3]$ is a sum of squares if and only if it belongs to the smaller semidomain $\nn_0[4/9]$, and this can be decided by a simple algorithm. We also bound the number of squares needed in terms of the denominator of the element, and we show that whether an element is a sum of one or two squares can be decided by a finite computation. The second question, namely, computing the least number of squares needed by an arbitrary element of $\nn_0[2/3]$, remains open.
\smallskip

This paper is organized as follows. In Section~\ref{sec:background}, we introduce the notation and terminology we will use throughout this paper, and we recall the classical theorems on sums of squares of integers that we will need. In Section~\ref{sec:universal}, we prove part~(1) of the Main Theorem together with the first statement of part~(2), and we illustrate with some examples the role played by the ambient semidomain. In Section~\ref{sec:pythagoras}, we establish a rigidity property of polynomials whose coefficients belong to $\{0,1\}$, and we use it to complete the proof of the Main Theorem. Finally, in Section~\ref{sec:two-thirds}, we focus on the semidomain $\nn_0[2/3]$, and we conclude with some open questions.









\bigskip
%%%%%%%%%%%%
%%%%%%%%%%%%
\section{Background: The Standard Book of Spells}
\label{sec:background}

In this section, we introduce the notation and terminology we will use throughout this paper, and we recall the classical results on sums of squares of integers that we need later. For background on semirings, see \cite{jG99}. For the basics of witchcraft and wizardry, see~\cite{jR98}, and for the standard spells and their underlying theory, see \cite{mG65,aW52}.
\smallskip

Following standard notation, we let $\zz$, $\qq$, and $\rr$ denote the sets of integers, rational numbers, and real numbers, respectively. Additionally, we let $\nn$ denote the set of positive integers, and we set $\nn_0 := \{0\} \cup \nn$. Given $r \in \rr$ and $S \subseteq \rr$, we set $S_{\ge r} := \{s \in S : s \ge r\}$, and we define $S_{> r}$ in a similar way. For $m,n \in \zz$ with $m \le n$, we denote by $\ldb m,n \rdb$ the discrete interval from $m$ to $n$; that is, $\ldb m,n \rdb := \{k \in \zz : m \le k \le n\}$. For $q \in \qq_{>0}$, we let $\mathsf{n}(q)$ and $\mathsf{d}(q)$ denote the unique positive integers such that $q = \mathsf{n}(q)/\mathsf{d}(q)$ and $\gcd(\mathsf{n}(q),\mathsf{d}(q)) = 1$. For $b \in \nn$, we let $\zz[1/b]$ denote the ring of rational numbers that can be written as $m/b^k$ for some $m \in \zz$ and $k \in \nn_0$. As usual, for $m,n \in \nn$, we write $m \mid n$ when $m$ divides~$n$, while for elements $x$ and $y$ of a semidomain~$S$, we write $x \mid_S y$ when $y = xz$ for some $z \in S$. Finally, for $v_0, \dots, v_h \in \nn_0$, we set
\[
    \langle v_0, \dots, v_h \rangle := \{ c_0 v_0 + \dots + c_h v_h : c_0, \dots, c_h \in \nn_0 \},
\]
which is the additive submonoid of $\nn_0$ \emph{generated} by $v_0, \dots, v_h$.



\medskip
%%%%%%%%%%%%%%%%%%%%%%%
\subsection{The Wizarding World: Semidomains and Rational Monogenic Semidomains}

Recall that a commutative ring with identity is an \emph{integral domain} provided that it contains no nonzero zero-divisors.

\begin{definition}
    Let $R$ be an integral domain. A subset $S$ of $R$ is called a \emph{semidomain} if $0, 1 \in S$ and $S$ is closed under both addition and multiplication. A semidomain $S$ is called \emph{positive} if $S \subseteq \rr_{\ge 0}$.
\end{definition}

Here are some basic examples of semidomains.

\begin{example}
    Every integral domain is a semidomain. The sets $\nn_0$, $\qq_{\ge 0}$, and $\rr_{\ge 0}$ are positive semidomains. On the other hand, the set $\nn_0[X]$ of polynomials with nonnegative integer coefficients is a semidomain of the integral domain $\zz[X]$, but it is not a positive semidomain.
\end{example}

Semidomains have been studied from the point of view of factorization theory in \cite{GP23}. In this paper we focus on the following class of positive semidomains.

\begin{definition}
    For $q \in \qq_{>0}$, the \emph{rational monogenic semidomain} generated by~$q$ is
    \[
        S_q := \nn_0[q] := \{ f(q) : f \in \nn_0[X] \}.
    \]
\end{definition}

Since $f(q) + g(q) = (f+g)(q)$ and $f(q)g(q) = (fg)(q)$ for all $f,g \in \nn_0[X]$, the set $S_q$ is a positive semidomain containing~$q$. Moreover, every semidomain of~$\rr$ containing~$q$ contains $f(q)$ for each $f \in \nn_0[X]$, and so $S_q$ is the smallest semidomain of~$\rr$ containing~$q$. The additive monoid of $S_q$ is the Puiseux monoid generated by the geometric sequence $(q^n)_{n \ge 0}$, whose factorization invariants were studied in \cite{CGG20}, while the semidomains $S_q$ were investigated from the point of view of atomicity in \cite{ABP21}, where they are called exponential Puiseux semirings.

Let us look at three examples of rational monogenic semidomains.

\begin{example} \label{ex:three monogenic semidomains}
    \noindent
    \begin{enumerate}
        \item For $n \in \nn$, we see that $S_n = \nn_0$.
        \smallskip

        \item For $b \in \nn$, we see that $S_{1/b} = \{ m/b^k : m,k \in \nn_0 \} = \zz[1/b]_{\ge 0}$.
        \smallskip

        \item The semidomain $S_{2/3}$ contains $1$, $2/3$, $4/9$, $5/3 = 1 + 2/3$, and $13/9 = 1 + (2/3)^2$. As we will see in Example~\ref{ex:1/3 is not in S_2/3}, the semidomain $S_{2/3}$ does not contain $1/3$. \qedhere
    \end{enumerate}
\end{example}

The following lemma collects three basic properties of rational monogenic semidomains that we will use repeatedly throughout this paper.

\begin{lemma} \label{lem:basic properties}
    Let $q = a/b$, where $a,b \in \nn$ and $\gcd(a,b) = 1$. Then the following statements hold.
    \begin{enumerate}
        \item The inclusion $S_q \subseteq \zz[1/b]$ holds.
        \smallskip

        \item If $q > 1$ then every element of $S_q$ that is smaller than $q$ belongs to $\nn_0$.
        \smallskip

        \item If $q < 1$ then every element of $S_q$ that is smaller than $1$ belongs to $qS_q := \{qx : x \in S_q\}$.
    \end{enumerate}
\end{lemma}

\begin{proof}
    (1) Take $f = \sum_{k=0}^d c_k X^k \in \nn_0[X]$. After clearing denominators, we see that $f(q) = \big( \sum_{k=0}^d c_k a^k b^{d-k} \big)/b^d \in \zz[1/b]$.
    \smallskip

    (2) Assume that $q > 1$, and take $f = \sum_{k=0}^d c_k X^k \in \nn_0[X]$ such that $f(q) < q$. If $c_k \neq 0$ for some $k \in \ldb 1,d \rdb$ then $f(q) \ge c_k q^k \ge q$ because $q > 1$, which is not possible. Hence $f = c_0$, and so $f(q) = c_0 \in \nn_0$.
    \smallskip

    (3) Assume that $q < 1$, and take $f \in \nn_0[X]$ such that $f(q) < 1$. If the constant coefficient of~$f$ were positive then $f(q) \ge 1$. Hence $f = Xg$ for some $g \in \nn_0[X]$, which implies that $f(q) = q\,g(q) \in qS_q$.
\end{proof}

The inclusion in part~(1) of Lemma~\ref{lem:basic properties} is not always an equality, as the following example illustrates.

\begin{example} \label{ex:1/3 is not in S_2/3}
    Set $q = 2/3$. By part~(1) of Lemma~\ref{lem:basic properties}, the inclusion $S_q \subseteq \zz[1/3]$ holds. However, $1/3 \notin S_q$. To argue this, suppose, by way of contradiction, that $1/3 \in S_q$. Since $1/3 < 1$, it follows from part~(3) of Lemma~\ref{lem:basic properties} that $1/3 = \sum_{k=1}^d c_k (2/3)^k$ for some $d \in \nn$ and $c_1, \dots, c_d \in \nn_0$. After multiplying both sides of this equality by $3^d$, we obtain that
    \[
        3^{d-1} = \sum_{k=1}^d c_k 2^k 3^{d-k},
    \]
    which is not possible because the left-hand side is odd while the right-hand side is even. On the other hand, observe that $3/2 \notin S_q$ because $3/2 \notin \zz[1/3]$.
\end{example}



\medskip
%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Ancient Runes: Classical Results over the Nonnegative Integers}

We proceed to recall the classical results on sums of squares of integers that motivated this paper (see~\cite{bB79} for their translation into ancient runes). Only parts~(2) and~(3) of the following theorem will be used in the proofs of our results.

\begin{theorem} \label{thm:classical}
    For each $n \in \nn$, the following statements hold.
    \begin{enumerate}
        \item \textup{\textsc{Fermat--Euler}} \cite[Chapter~XX]{HW08}: $n$ is a sum of two squares of integers if and only if every prime congruent to $3$ modulo~$4$ appears with an even exponent in the prime factorization of~$n$.
        \smallskip

        \item \textup{\textsc{Legendre--Gauss}} \cite[Chapter~1]{mN96}: $n$ is a sum of three squares of integers if and only if $n \neq 4^h(8j+7)$ for all $h,j \in \nn_0$.
        \smallskip

        \item \textup{\textsc{Lagrange}} \cite[Chapter~XX]{HW08}: $n$ is a sum of four squares of integers.
    \end{enumerate}
\end{theorem}

Let us take a look at an example.

\begin{example} \label{ex:classical}
    Observe that $13 = 2^2 + 3^2$ is a sum of two squares, which is consistent with the fact that $13 \equiv 1 \pmod 4$ is a prime. Since $3$ appears with exponent~$1$ in the prime factorization of $21 = 3 \cdot 7$, the integer $21$ is not a sum of two squares, but it is a sum of three squares: $21 = 4^2 + 2^2 + 1^2$. On the other hand, $7 = 2^2 + 1^2 + 1^2 + 1^2$ is not a sum of three squares because it has the form $4^0(8 \cdot 0 + 7)$. Similarly, $28 = 5^2 + 1^2 + 1^2 + 1^2$ is not a sum of three squares because it has the form $4^1(8 \cdot 0 + 7)$.
\end{example}

The number~$7$, which Tom Riddle considered the most powerfully magical number \cite{jR05}, will play a crucial role in Section~\ref{sec:universal}. We conclude this subsection with two further celebrated results, which we will not use but which illustrate how much is known about sums of squares of integers.

\begin{remark}
    For each $n \in \nn$, let $r_4(n)$ be the number of quadruples $(x_1, \dots, x_4) \in \zz^4$ such that $x_1^2 + \dots + x_4^2 = n$, where the order of the entries matters. Then Jacobi's four-square theorem (see \cite[Chapter~XX]{HW08}) states that
    \[
        r_4(n) = 8 \sum_{\substack{d \mid n \\ 4 \nmid d}} d.
    \]
    On the other hand, if $B(x)$ denotes the number of positive integers at most $x$ that are sums of two squares then Landau's theorem states that $B(x) \sim K x/\sqrt{\log x}$ as $x \to \infty$, where $K \approx 0.7642$ is the Landau--Ramanujan constant (see the survey \cite{BM24}).
\end{remark}



\medskip
%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Ollivander's Measurements: Sums of Squares in Positive Semidomains}

We are now in a position to introduce the main definitions of this paper. Just as Mr.\ Ollivander carefully measures every wand before it chooses its wizard~\cite{gO80}, we measure each element of a positive semidomain by the number of squares it needs.

\begin{definition}
    Let $S$ be a positive semidomain. We set
    \[
        \sos S^2 := \bigg\{ \sum_{i=1}^r x_i^2 : r \in \nn_0 \text{ and } x_1, \dots, x_r \in S \bigg\},
    \]
    where the empty sum is~$0$. For each $s \in S$, the \emph{square length} of~$s$ is
    \[
        \ell_S(s) := \min \{ r \in \nn_0 : s = x_1^2 + \dots + x_r^2 \text{ for some } x_1, \dots, x_r \in S \},
    \]
    where $\ell_S(s) := \infty$ if $s \notin \sos S^2$. The \emph{universal square bound} and the \emph{Pythagoras number} of~$S$ are, respectively,
    \[
        u(S) := \sup \{ \ell_S(s) : s \in S \} \quad \text{ and } \quad p(S) := \sup \{ \ell_S(s) : s \in \sos S^2 \}.
    \]
    For $q \in \qq_{>0}$, we write $u(q)$ and $p(q)$ instead of $u(S_q)$ and $p(S_q)$, respectively.
\end{definition}

Since $0 = 0^2$, repeated and zero summands are allowed in our representations, and so an element is a sum of at most $r$ squares if and only if it is a sum of exactly $r$ squares. Since $\sos S^2 \subseteq S$, the inequality $p(S) \le u(S)$ holds. Also, if $u(S)$ is finite then $\ell_S(s) < \infty$ for every $s \in S$, which means that $S = \sos S^2$.

Let us compute these invariants for three familiar positive semidomains.

\begin{example} \label{ex:invariants}
    \noindent
    \begin{enumerate}
        \item For $S = \nn_0$, it follows from Lagrange's theorem that $\sos S^2 = S$ and $u(S) \le 4$. By Example~\ref{ex:classical}, we see that $\ell_S(13) = 2$, $\ell_S(21) = 3$, and $\ell_S(7) = \ell_S(28) = 4$. Hence $u(\nn_0) = p(\nn_0) = 4$.
        \smallskip

        \item For $S = \qq_{\ge 0}$, take $m \in \nn_0$ and $n \in \nn$. By Lagrange's theorem, there exist $v_1, \dots, v_4 \in \nn_0$ such that $mn = v_1^2 + \dots + v_4^2$, and so
        \[
            \frac mn = \frac{mn}{n^2} = \Big( \frac{v_1}n \Big)^2 + \dots + \Big( \frac{v_4}n \Big)^2.
        \]
        Hence $u(\qq_{\ge 0}) \le 4$. We will see in Proposition~\ref{prop:seven} that $u(\qq_{\ge 0}) = p(\qq_{\ge 0}) = 4$.
        \smallskip

        \item For $S = \rr_{\ge 0}$, every element is the square of its square root, and so $u(\rr_{\ge 0}) = p(\rr_{\ge 0}) = 1$. \qedhere
    \end{enumerate}
\end{example}

The set $\sos S^2$ is not only closed under addition, but also under multiplication.

\begin{lemma} \label{lem:sos is a semidomain}
    If $S$ is a positive semidomain then $\sos S^2$ is a semidomain contained in $S$.
\end{lemma}

\begin{proof}
    Since $0 = 0^2$ and $1 = 1^2$, both $0$ and $1$ belong to $\sos S^2$. In addition, the sum of two sums of squares is again a sum of squares, and so $\sos S^2$ is closed under addition. To see that $\sos S^2$ is also closed under multiplication, take $x_1, \dots, x_r, y_1, \dots, y_n \in S$, and observe that
    \[
        \bigg( \sum_{i=1}^r x_i^2 \bigg) \bigg( \sum_{j=1}^n y_j^2 \bigg) = \sum_{i=1}^r \sum_{j=1}^n (x_i y_j)^2 \in \sos S^2. \qedhere
    \]
\end{proof}









\bigskip
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
\section{The Order of the Four Squares: Universal Square Bounds}
\label{sec:universal}

In this section, we determine the rational monogenic semidomains in which every element is a sum of squares, which yields part~(1) of the Main Theorem and the first statement of part~(2). We start by showing that the number~$7$ needs four squares in every positive semidomain consisting of rational numbers.

\begin{prop} \label{prop:seven}
    Let $S$ be a semidomain contained in $\qq_{\ge 0}$. Then $\ell_S(7) = 4$. In particular, $p(S) \ge 4$.
\end{prop}

\begin{proof}
    Since $\nn_0 \subseteq S$, the equality $7 = 2^2 + 1^2 + 1^2 + 1^2$ ensures that $\ell_S(7) \le 4$. To prove the reverse inequality, it suffices to show that $7$ is not a sum of three squares of rational numbers. Suppose, by way of contradiction, that $7 = x_1^2 + x_2^2 + x_3^2$ for some $x_1, x_2, x_3 \in \qq$. After clearing a common positive denominator $w$, we can write $7w^2$ as a sum of three squares of integers. Now write $w = 2^h v$, where $h \in \nn_0$ and $v$ is an odd positive integer. Since $v^2 \equiv 1 \pmod 8$, we see that $7v^2 \equiv 7 \pmod 8$, and so $7w^2 = 4^h(7v^2)$ has the form excluded by part~(2) of Theorem~\ref{thm:classical}. This contradiction shows that $\ell_S(7) = 4$. Since $7 \in \sos S^2$, we conclude that $p(S) \ge \ell_S(7) = 4$.
\end{proof}

We are now ready to prove the main result of this section.

\begin{theorem} \label{thm:classification}
    Let $q = a/b$, where $a,b \in \nn$ and $\gcd(a,b) = 1$. Then the following conditions are equivalent.
    \begin{enumerate}
        \item[(a)] The universal square bound $u(q)$ is finite.
        \smallskip

        \item[(b)] Every element of $S_q$ is a sum of squares of elements of $S_q$.
        \smallskip

        \item[(c)] The generator $q$ is a sum of squares of elements of $S_q$.
        \smallskip

        \item[(d)] Either $a = 1$ or $b = 1$.
    \end{enumerate}
    Moreover, if the conditions above hold then $u(q) = p(q) = 4$.
\end{theorem}

\begin{proof}
    (a)~$\Rightarrow$~(b)~$\Rightarrow$~(c): If $u(q)$ is finite then $\ell_{S_q}(s) < \infty$ for every $s \in S_q$, which is condition~(b), and (b) implies~(c) because $q \in S_q$.
    \smallskip

    (c)~$\Rightarrow$~(d): Suppose, by way of contradiction, that $a > 1$ and $b > 1$, and that
    \[
        q = x_1^2 + \dots + x_r^2
    \]
    for some $r \in \nn$ and $x_1, \dots, x_r \in S_q$. Since all the summands are nonnegative, $x_i \le \sqrt q$ for every $i \in \ldb 1,r \rdb$. Observe that $q \neq 1$ because $b > 1$. We split the rest of the proof into two cases.
    \smallskip

    \textsc{Case 1:} $q > 1$. In this case, $x_i \le \sqrt q < q$ for every $i \in \ldb 1,r \rdb$, and so it follows from part~(2) of Lemma~\ref{lem:basic properties} that $x_1, \dots, x_r \in \nn_0$. As a consequence, $q = x_1^2 + \dots + x_r^2 \in \nn_0$, which contradicts that $b > 1$.
    \smallskip

    \textsc{Case 2:} $q < 1$. In this case, $x_i \le \sqrt q < 1$ for every $i \in \ldb 1,r \rdb$, and so it follows from part~(3) of Lemma~\ref{lem:basic properties} that, for each $i \in \ldb 1,r \rdb$, we can write $x_i = q y_i$ for some $y_i \in S_q$. Dividing both sides of $q = q^2 \sum_{i=1}^r y_i^2$ by $q^2$, we obtain that
    \[
        \frac ba = \frac 1q = y_1^2 + \dots + y_r^2 \in S_q.
    \]
    By part~(1) of Lemma~\ref{lem:basic properties}, we see that $b/a \in \zz[1/b]$, and so $b/a = c/b^k$ for some $c \in \zz$ and $k \in \nn_0$. This implies that $a \mid b^{k+1}$, which contradicts that $a > 1$ and $\gcd(a,b) = 1$.
    \smallskip

    \noindent From \textsc{Case 1} and \textsc{Case 2}, we conclude that either $a = 1$ or $b = 1$.
    \smallskip

    (d)~$\Rightarrow$~(a): If $b = 1$ then $S_q = \nn_0$, and so Lagrange's theorem guarantees that $u(q) \le 4$. Suppose now that $a = 1$, and so $S_q = \{m/b^k : m,k \in \nn_0\}$. Fix $s = m/b^k \in S_q$, and take $h \in \nn_0$ such that $2h \ge k$. By Lagrange's theorem, there exist $v_1, \dots, v_4 \in \nn_0$ such that $m b^{2h-k} = v_1^2 + \dots + v_4^2$, which implies that
    \[
        s = \frac{m b^{2h-k}}{b^{2h}} = \Big( \frac{v_1}{b^h} \Big)^2 + \dots + \Big( \frac{v_4}{b^h} \Big)^2.
    \]
    Since $v_i/b^h \in S_q$ for every $i \in \ldb 1,4 \rdb$, we obtain that $u(q) \le 4$.
    \smallskip

    Finally, assume that the equivalent conditions (a)--(d) hold. Then $S_q = \sos S_q^2$, and so $u(q) = p(q)$. In addition, we have seen that $u(q) \le 4$, and it follows from Proposition~\ref{prop:seven} that $p(q) \ge 4$. Hence $u(q) = p(q) = 4$.
\end{proof}

As an immediate consequence of Theorem~\ref{thm:classification}, we obtain the following corollary.

\begin{cor} \label{cor:universal bound}
    For each $q \in \qq_{>0}$,
    \[
        u(q) =
        \begin{cases}
            4 & \text{ if } \mathsf{n}(q) = 1 \text{ or } \mathsf{d}(q) = 1, \\
            \infty & \text{ if } \mathsf{n}(q) > 1 \text{ and } \mathsf{d}(q) > 1.
        \end{cases}
    \]
\end{cor}

The following remark gives a second argument for one of the equivalences in Theorem~\ref{thm:classification}.

\begin{remark}
    The equivalence (b)~$\Leftrightarrow$~(c) in Theorem~\ref{thm:classification} also follows directly from Lemma~\ref{lem:sos is a semidomain}: if the semidomain $\sos S_q^2$ contains~$q$ then it must contain every polynomial expression in~$q$ with nonnegative integer coefficients, and so $\sos S_q^2 = S_q$.
\end{remark}



\medskip
%%%%%%%%%%%%%%%%%%%
\subsection{No Magic Outside Hogwarts: The Role of the Ambient Semidomain}

We conclude this section with some examples illustrating Theorem~\ref{thm:classification} and the role played by the semidomain $S_q$ in which the square roots are required to live.

\begin{example} \label{ex:one third}
    Set $q = 1/3$. By Theorem~\ref{thm:classification}, every element of $S_q$ is a sum of at most four squares of elements of $S_q$. For instance,
    \[
        \frac 79 = \Big( \frac 23 \Big)^2 + \Big( \frac 13 \Big)^2 + \Big( \frac 13 \Big)^2 + \Big( \frac 13 \Big)^2.
    \]
    In addition, $\ell_{S_q}(7/9) = 4$: indeed, if $7/9$ were a sum of three squares of elements of $S_q$ then after multiplying by~$9$, we would obtain that $7$ is a sum of three squares of elements of $\qq_{\ge 0}$, which is not possible by Proposition~\ref{prop:seven} applied to $S = \qq_{\ge 0}$.
\end{example}

\begin{example} \label{ex:Snape}
    Set $q = 3/2$. It follows from part~(2) of Lemma~\ref{lem:basic properties} that every element of $S_q$ that is smaller than $q$ is an integer. Therefore every square root appearing in a sum-of-squares representation of~$q$ in $S_q$ must be an integer because it is at most $\sqrt q < q$. As $q$ is not an integer, $q$ is not a sum of squares of elements of~$S_q$. This argument is a special case of \textsc{Case~1} in the proof of Theorem~\ref{thm:classification}.
\end{example}

\begin{example} \label{ex:two thirds}
    Set $q = 2/3$, and suppose that $q = x_1^2 + \dots + x_r^2$ for some $x_1, \dots, x_r \in S_q$. Since $x_i \le \sqrt q < 1$ for every $i \in \ldb 1,r \rdb$, it follows from part~(3) of Lemma~\ref{lem:basic properties} that $x_i = qy_i$ for some $y_i \in S_q$, and dividing by $q^2$ yields $3/2 = y_1^2 + \dots + y_r^2 \in S_q$, which is not the case by Example~\ref{ex:1/3 is not in S_2/3}. Hence $q$ is not a sum of squares of elements of~$S_q$. Thus, the equality
    \[
        \frac23 = \Big( \frac23 \Big)^2 + \Big( \frac13 \Big)^2 + \Big( \frac13 \Big)^2
    \]
    does not contradict our conclusion, as $1/3 \notin S_q$. This equality is the source of the claim in~\cite{xL95} that $2/3$ is a sum of three squares in $S_q$, a claim that overlooks the fact that $1/3 \notin S_q$.
\end{example}

These examples show that a representation of an element of~$S_q$ as a sum of squares in $\qq_{\ge 0}$ does not automatically yield a representation as a sum of squares in $S_q$. Indeed, it follows from part~(2) of Example~\ref{ex:invariants} that every element of~$S_q$ is a sum of four squares of nonnegative rational numbers, but the corresponding square roots do not necessarily belong to the semidomain $S_q$.









\bigskip
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
\section{The Room of Requirement: Pythagoras Numbers}
\label{sec:pythagoras}

In this section, we determine the Pythagoras number of every rational monogenic semidomain, which completes the proof of the Main Theorem. Unlike the universal square bound, the Pythagoras number only concerns the elements that are sums of squares. Like the Room of Requirement, which provides whatever its visitors need, the semidomain $S_q$ will provide elements needing as many squares as we wish whenever $\mathsf{n}(q) > 1$ and $\mathsf{d}(q) > 1$, and, unlike many of the creatures described in~\cite{nS27}, such elements are easy to find. The key observation is that, when $\mathsf{n}(q) > 1$ and $\mathsf{d}(q) > 1$, a polynomial with coefficients in $\{0,1\}$ is uniquely determined, among all the polynomials in $\nn_0[X]$, by its value at~$q$. To prove this, we need the following definition.

\begin{definition}
    Let $q = a/b$, where $a,b \in \nn$ and $\gcd(a,b) = 1$. We say that a polynomial $f \in \nn_0[X]$ is \emph{$q$-reduced} if, for every $k \in \nn$, the coefficient of $X^k$ in~$f$ belongs to $\ldb 0, b-1 \rdb$ (the constant coefficient of~$f$ is unrestricted).
\end{definition}

Let us illustrate this definition with an example.

\begin{example} \label{ex:reduced}
    Set $q = 2/3$. The polynomial $1 + 2X + X^2$ is $q$-reduced, while the polynomial $g = 3X^3 + 1$ is not. Since $3q^3 = 2q^2$, the polynomial $g$ and the $q$-reduced polynomial $2X^2 + 1$ have the same value at~$q$, namely, $17/9$.
\end{example}

As Example~\ref{ex:reduced} suggests, the identity $bq^k = aq^{k-1}$ allows us to replace every polynomial in $\nn_0[X]$ by a $q$-reduced polynomial with the same value at~$q$; in the terminology of \cite[Chapter~4]{aD62}, each such replacement is an elementary transfiguration.

\begin{lemma} \label{lem:reduced}
    Let $q = a/b$, where $a,b \in \nn$ and $\gcd(a,b) = 1$. For each $g \in \nn_0[X]$, there exists a unique $q$-reduced polynomial $f \in \nn_0[X]$ such that $f(q) = g(q)$. Moreover, $f$ can be obtained from~$g$ by applying finitely many replacements of the form $bX^k \mapsto aX^{k-1}$ for $k \in \nn$, starting at the highest degree and proceeding downward.
\end{lemma}

\begin{proof}
    Since $bq^k = aq^{k-1}$ for every $k \in \nn$, the replacement $bX^k \mapsto aX^{k-1}$ preserves the value at~$q$ and keeps all coefficients nonnegative. Let $d$ be the degree of~$g$. For each $k$ from $d$ down to~$1$, we apply the replacement $bX^k \mapsto aX^{k-1}$ as many times as needed to make the coefficient of $X^k$ smaller than~$b$; since these replacements only increase the coefficient of $X^{k-1}$, they do not modify the coefficients of degree larger than~$k$, which have already been reduced. As a result, this process terminates in a $q$-reduced polynomial $f$ with $f(q) = g(q)$.
    \smallskip

    To argue uniqueness, suppose that $f_1$ and $f_2$ are two distinct $q$-reduced polynomials such that $f_1(q) = f_2(q)$, and write $f_1 - f_2 = \sum_{k=0}^d e_k X^k$ with $e_d \neq 0$. If $d = 0$ then $f_1(q) - f_2(q) = e_0 \neq 0$, which is not possible. Therefore $d \ge 1$, and so $0 < |e_d| < b$ because both $f_1$ and $f_2$ are $q$-reduced. Multiplying the equality $\sum_{k=0}^d e_k q^k = 0$ by $b^d$, we obtain that
    \[
        \sum_{k=0}^d e_k a^k b^{d-k} = 0.
    \]
    After reducing this equality modulo~$b$, we see that $b \mid_{\zz} e_d a^d$. Since $\gcd(a,b) = 1$, this implies that $b \mid_{\zz} e_d$, which contradicts that $0 < |e_d| < b$.
\end{proof}

We are now in a position to establish the rigidity property mentioned at the beginning of this section.

\begin{lemma} \label{lem:binary rigidity}
    Let $q = a/b$, where $a,b \in \nn_{\ge 2}$ and $\gcd(a,b) = 1$. If $f \in \nn_0[X]$ has all its coefficients in $\{0,1\}$ and $g \in \nn_0[X]$ satisfies $g(q) = f(q)$ then $g = f$.
\end{lemma}

\begin{proof}
    Since $b \ge 2$, the polynomial $f$ is $q$-reduced. Therefore it follows from Lemma~\ref{lem:reduced} that $f$ is obtained from~$g$ after applying finitely many replacements of the form $bX^k \mapsto aX^{k-1}$. Suppose, by way of contradiction, that at least one replacement is applied, and let $H \in \nn_0[X]$ be the polynomial right before the last replacement. Then
    \[
        f = H - bX^k + aX^{k-1}
    \]
    for some $k \in \nn$. If $c \in \nn_0$ is the coefficient of $X^{k-1}$ in~$H$ then the coefficient of $X^{k-1}$ in~$f$ is $c + a \ge a \ge 2$, which contradicts that all the coefficients of~$f$ belong to $\{0,1\}$. Hence no replacement is applied, and so $g = f$.
\end{proof}

The hypothesis that both $a$ and $b$ are at least~$2$ cannot be dropped in Lemma~\ref{lem:binary rigidity}.

\begin{example}
    For $q = 1/2$, the polynomials $X$ and $2X^2$ are distinct and have the same value at~$q$, namely, $1/2$. Similarly, for $q = 2$, the polynomials $X$ and $2$ are distinct and have the same value at~$q$.
\end{example}

We are now ready to prove the main result of this section, which says that, when $\mathsf{n}(q) > 1$ and $\mathsf{d}(q) > 1$, for each $N \in \nn$, there are elements of~$S_q$ whose square length is~$N$.

\begin{theorem} \label{thm:prescribed square length}
    Let $q = a/b$, where $a,b \in \nn_{\ge 2}$ and $\gcd(a,b) = 1$. For each $N \in \nn$, the element
    \[
        s_N := \sum_{j=0}^{N-1} q^{2j}
    \]
    of $S_q$ satisfies $\ell_{S_q}(s_N) = N$. In fact, every representation of $s_N$ as a sum of nonzero squares of elements of $S_q$ has exactly $N$ summands. As a consequence, $p(q) = \infty$.
\end{theorem}

\begin{proof}
    Since $s_N$ is, by definition, a sum of $N$ squares of elements of $S_q$, the inequality $\ell_{S_q}(s_N) \le N$ holds. Now suppose that
    \[
        s_N = \sum_{i=1}^r x_i^2
    \]
    for some $r \in \nn$ and $x_1, \dots, x_r \in S_q \setminus \{0\}$. For each $i \in \ldb 1,r \rdb$, take a nonzero polynomial $g_i \in \nn_0[X]$ such that $g_i(q) = x_i$. Since all the coefficients of $\sum_{j=0}^{N-1} X^{2j}$ belong to $\{0,1\}$, it follows from Lemma~\ref{lem:binary rigidity} that
    \begin{equation} \label{eq:polynomial identity}
        \sum_{i=1}^r g_i(X)^2 = \sum_{j=0}^{N-1} X^{2j}.
    \end{equation}
    All the coefficients of the left-hand side of~\eqref{eq:polynomial identity} are nonnegative, while all the coefficients of its right-hand side are at most~$1$. If, for some $i \in \ldb 1,r \rdb$, the polynomial $g_i$ had a coefficient at least~$2$ then $g_i^2$ would have a coefficient at least~$4$. Similarly, if $g_i$ had two distinct nonzero terms then the corresponding cross term would yield a coefficient at least~$2$ in $g_i^2$. Since both conclusions contradict~\eqref{eq:polynomial identity}, each $g_i$ must be a monomial with coefficient~$1$. Thus, \eqref{eq:polynomial identity} expresses the $N$ distinct monomials on its right-hand side as a sum of $r$ monomials with coefficient~$1$, which implies that $r = N$. Finally, since $N$ was arbitrarily taken, $p(q) = \infty$.
\end{proof}

We now specialize Theorem~\ref{thm:prescribed square length} to the generator $2/3$.

\begin{example} \label{ex:two thirds unbounded length}
    Set $q = 2/3$. In this case, Theorem~\ref{thm:prescribed square length} guarantees that
    \[
        \ell_{S_q}\bigg( \sum_{j=0}^{N-1} \Big( \frac 23 \Big)^{2j} \bigg) = N
    \]
    for every $N \in \nn$. The first four elements of this sequence are $1$, $13/9$, $133/81$, and $1261/729$, whose square lengths are $1$, $2$, $3$, and $4$, respectively. Moreover,
    \[
        s_N = \frac 95 \bigg( 1 - \Big( \frac 49 \Big)^N \bigg) < \frac 95
    \]
    for every $N \in \nn$. Thus, square lengths are unbounded even among the sums of squares of elements of $S_q$ in a bounded interval. Observe that this conclusion is stronger than the fact that $2/3$ is not a sum of squares of elements of $S_q$ (see Example~\ref{ex:two thirds}) because it concerns elements that are, indeed, sums of squares.
\end{example}

Putting together Theorem~\ref{thm:classification} and Theorem~\ref{thm:prescribed square length}, we obtain the following classification.

\begin{cor} \label{cor:pythagoras classification}
    For each $q \in \qq_{>0}$,
    \[
        p(q) =
        \begin{cases}
            4 & \text{ if } \mathsf{n}(q) = 1 \text{ or } \mathsf{d}(q) = 1, \\
            \infty & \text{ if } \mathsf{n}(q) > 1 \text{ and } \mathsf{d}(q) > 1.
        \end{cases}
    \]
\end{cor}

\begin{proof}[Proof of the Main Theorem]
    Part~(1) follows from Theorem~\ref{thm:classification} and Proposition~\ref{prop:seven}. The first statement of part~(2) follows from Theorem~\ref{thm:classification}, while the second statement of part~(2) follows from Theorem~\ref{thm:prescribed square length}.
\end{proof}

Comparing Corollary~\ref{cor:universal bound} and Corollary~\ref{cor:pythagoras classification}, we see that, although the universal square bound and the Pythagoras number have different definitions, the equality $u(q) = p(q)$ holds for every $q \in \qq_{>0}$.









\bigskip
%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%
\section{The Chamber of Two Thirds: The Semidomain \texorpdfstring{$\nn_0[2/3]$}{N0[2/3]}}
\label{sec:two-thirds}

Throughout this section, we set
\[
    q := \frac 23, \qquad S := S_q = \nn_0\Big[ \frac 23 \Big], \qquad \text{ and } \qquad t := q^2 = \frac 49.
\]
By Theorem~\ref{thm:classification}, not every element of~$S$ is a sum of squares of elements of~$S$. Our purpose here is to identify the elements of~$S$ that are sums of squares, to give an algorithm deciding whether a given element of~$S$ is a sum of squares, and to bound its square length.



\smallskip
%%%%%%%%%%%%%%%%%%%
\subsection{Revelio: The Semiring of Sums of Squares}

Our first result identifies the semidomain $\sos S^2$. The crucial identity is $3q^2 = 2q$, which allows us to rewrite every cross term of the form $2q^{2k+1}$ as an integer multiple of a power of~$t$.

\begin{prop} \label{prop:sos semiring}
    The equality $\sos S^2 = \nn_0[t]$ holds.
\end{prop}

\begin{proof}
    Every element of $\nn_0[t]$ is a finite sum of nonnegative integer multiples of the elements $t^j = (q^j)^2$, which implies that $\nn_0[t] \subseteq \sos S^2$. For the reverse inclusion, it suffices to show that the square of every element of~$S$ belongs to $\nn_0[t]$ because $\nn_0[t]$ is closed under addition. Write an element of~$S$ as $x = \sum_{i=0}^d c_i q^i$, where $d \in \nn_0$ and $c_0, \dots, c_d \in \nn_0$. Then
    \[
        x^2 = \sum_{i=0}^d c_i^2 q^{2i} + \sum_{0 \le i < j \le d} 2c_ic_j q^{i+j}.
    \]
    The terms in the first sum and the terms in the second sum with $i+j$ even belong to $\nn_0[t]$. For the remaining terms, observe that the identity
    \[
        2q^{2k+1} = q^{2k}(2q) = q^{2k}(3q^2) = 3t^{k+1}
    \]
    holds for every $k \in \nn_0$. Therefore $x^2 \in \nn_0[t]$, and so $\sos S^2 \subseteq \nn_0[t]$.
\end{proof}

Let us illustrate the proof of Proposition~\ref{prop:sos semiring} with an example.

\begin{example}
    For $x = 1 + q = 5/3$, the proof of Proposition~\ref{prop:sos semiring} yields
    \[
        x^2 = 1 + 2q + q^2 = 1 + 3t + t = 1 + 4t,
    \]
    which is consistent with the fact that $25/9 = 1 + 4 \cdot (4/9)$. On the other hand, it follows from Proposition~\ref{prop:sos semiring} that $2/3 \notin \nn_0[t]$, since $2/3$ is not a sum of squares of elements of~$S$ (Example~\ref{ex:two thirds}).
\end{example}



\medskip
%%%%%%%%%%%%%%%%%%%
\subsection{The Sorting Hat: Deciding Whether an Element Is a Sum of Squares}

Every element of~$S$ can be written as $m/9^h$ for some $m,h \in \nn_0$ because, by part~(1) of Lemma~\ref{lem:basic properties}, its denominator is a power of~$3$. The next proposition reduces the problem of deciding whether $m/9^h$ is a sum of squares to deciding whether $m$ belongs to a finitely generated additive submonoid of $\nn_0$.

\begin{prop} \label{prop:finite test}
    For all $m,h \in \nn_0$,
    \[
        \frac{m}{9^h} \in \sos S^2 \quad \Longleftrightarrow \quad m \in \langle 4^i 9^{h-i} : i \in \ldb 0,h \rdb \rangle.
    \]
\end{prop}

\begin{proof}
    For the reverse implication, if $m = \sum_{i=0}^h e_i 4^i 9^{h-i}$ for some $e_0, \dots, e_h \in \nn_0$ then $m/9^h = \sum_{i=0}^h e_i t^i \in \nn_0[t]$, and so $m/9^h \in \sos S^2$ by Proposition~\ref{prop:sos semiring}.
    \smallskip

    For the direct implication, suppose that $m/9^h \in \sos S^2$. By Proposition~\ref{prop:sos semiring}, there exists $F \in \nn_0[X]$ such that $F(t) = m/9^h$. Since $t = 4/9$ and $\gcd(4,9) = 1$, we can assume, by virtue of Lemma~\ref{lem:reduced}, that $F$ is $t$-reduced, that is, all the coefficients of positive degree of~$F$ belong to $\ldb 0,8 \rdb$. We claim that $\deg F \le h$. Suppose, by way of contradiction, that $d := \deg F > h$, and write $F = \sum_{i=0}^d e_i X^i$, where $e_d \in \ldb 1,8 \rdb$. After multiplying the equality $m/9^h = F(t)$ by $9^d$, we obtain that
    \[
        m 9^{d-h} = \sum_{i=0}^d e_i 4^i 9^{d-i}.
    \]
    Reducing this equality modulo~$9$, we see that $9 \mid e_d 4^d$. Since $\gcd(4,9) = 1$, this implies that $9 \mid e_d$, which contradicts that $e_d \in \ldb 1,8 \rdb$. Hence $\deg F \le h$, and so we can write $m/9^h = \sum_{i=0}^h e_i t^i$ for some $e_0, \dots, e_h \in \nn_0$. Multiplying this equality by $9^h$, we conclude that $m = \sum_{i=0}^h e_i 4^i 9^{h-i}$.
\end{proof}

The finite test in Proposition~\ref{prop:finite test} can be carried out by the following algorithm, which uses exactly $h$ iterations. Throughout the algorithm, the residue of an integer modulo~$4$ is always taken in $\ldb 0,3 \rdb$, including the case when the integer is negative.
\smallskip

\noindent \textsc{Algorithm.} Input: $m,h \in \nn_0$.
\begin{enumerate}
    \item Set $M_0 := m$.
    \smallskip

    \item For each $i \in \ldb 0, h-1 \rdb$, let $c_i \in \ldb 0,3 \rdb$ be the residue of $M_i$ modulo~$4$, and set
    \[
        M_{i+1} := \frac{M_i - c_i 9^{h-i}}4.
    \]

    \item Set $c_h := M_h$. If $c_h \ge 0$ then output ``sum of squares'' together with the coefficients $c_0, \dots, c_h$. Otherwise, output ``not a sum of squares''.
\end{enumerate}
\smallskip

The next proposition shows that the algorithm is correct.

\begin{prop} \label{prop:algorithm}
    For all $m,h \in \nn_0$, the coefficients $c_0, \dots, c_h$ computed by the algorithm above are integers satisfying
    \begin{equation} \label{eq:digit expansion}
        \frac{m}{9^h} = \sum_{i=0}^h c_i t^i \quad \text{ and } \quad c_i \in \ldb 0,3 \rdb \ \text{ for every } i \in \ldb 0, h-1 \rdb,
    \end{equation}
    and they are the only integers satisfying~\eqref{eq:digit expansion}. Moreover, $m/9^h \in \sos S^2$ if and only if $c_h \ge 0$.
\end{prop}

\begin{proof}
    Since $9^{h-i} \equiv 1 \pmod 4$, we see that $M_i - c_i 9^{h-i} \equiv M_i - c_i \equiv 0 \pmod 4$, and so $M_{i+1} \in \zz$ for every $i \in \ldb 0, h-1 \rdb$. Iterating the defining recurrence, we obtain that
    \begin{equation} \label{eq:integer digit expansion}
        m = \sum_{i=0}^{h-1} c_i 4^i 9^{h-i} + 4^h c_h,
    \end{equation}
    and dividing by $9^h$ yields the equality in~\eqref{eq:digit expansion}. As for uniqueness, suppose that integers $c'_0, \dots, c'_h$ also satisfy~\eqref{eq:digit expansion}. Then they also satisfy~\eqref{eq:integer digit expansion}, and reducing~\eqref{eq:integer digit expansion} modulo~$4$, we see that $c'_0 \equiv m \equiv c_0 \pmod 4$, which implies that $c'_0 = c_0$ because $c_0, c'_0 \in \ldb 0,3 \rdb$. Subtracting $c_0 9^h$ from both sides of~\eqref{eq:integer digit expansion} and dividing by~$4$, we can repeat the same argument to show that $c'_1 = c_1$, and so on, until we obtain that $c'_h = c_h$.
    \smallskip

    If $c_h \ge 0$ then all the coefficients $c_0, \dots, c_h$ are nonnegative, and so $m/9^h \in \nn_0[t] = \sos S^2$ by Proposition~\ref{prop:sos semiring}. Conversely, suppose that $m/9^h \in \sos S^2$. By Proposition~\ref{prop:finite test}, we can write $m = \sum_{i=0}^h e_i 4^i 9^{h-i}$, that is, $m/9^h = \sum_{i=0}^h e_i t^i$, for some $e_0, \dots, e_h \in \nn_0$. Since $4t^i = 9t^{i+1}$ for every $i \in \nn_0$, we can apply the replacements $4X^i \mapsto 9X^{i+1}$, for $i$ from~$0$ up to $h-1$, to make every coefficient of degree less than~$h$ smaller than~$4$. These replacements preserve the value at~$t$ and keep all the coefficients nonnegative. By uniqueness, the resulting coefficients are precisely $c_0, \dots, c_h$, and so $c_h \ge 0$.
\end{proof}

\begin{table}[ht]
    \centering
    \begin{tabular}{cccl}
        \toprule
        $s$ & $(m,h)$ & $(c_0, \dots, c_h)$ & output \\
        \midrule
        $1/9$ & $(1,1)$ & $(1,-2)$ & not a sum of squares \\
        $2/3$ & $(6,1)$ & $(2,-3)$ & not a sum of squares \\
        $2/3$ & $(54,2)$ & $(2,1,-9)$ & not a sum of squares \\
        $13/9$ & $(13,1)$ & $(1,1)$ & sum of squares: $1 + t$ \\
        $25/9$ & $(25,1)$ & $(1,4)$ & sum of squares: $1 + 4t$ \\
        $37/9$ & $(37,1)$ & $(1,7)$ & sum of squares: $1 + 7t$ \\
        $17/3$ & $(51,1)$ & $(3,6)$ & sum of squares: $3 + 6t$ \\
        $133/81$ & $(133,2)$ & $(1,1,1)$ & sum of squares: $1 + t + t^2$ \\
        $1261/729$ & $(1261,3)$ & $(1,1,1,1)$ & sum of squares: $1 + t + t^2 + t^3$ \\
        \bottomrule
    \end{tabular}
    \medskip
    \caption{The output of the algorithm on some elements of $S = \nn_0[2/3]$.}
    \label{tab:algorithm}
\end{table}

We now run the algorithm on some elements of~$S$.

\begin{example} \label{ex:algorithm}
    In Table~\ref{tab:algorithm}, we show the output of the algorithm for some elements of~$S$. For instance, for $s = 2/3 = 6/9$, the algorithm yields $c_0 = 2$ and $c_1 = (6 - 2 \cdot 9)/4 = -3$, and so $2/3$ is not a sum of squares of elements of~$S$, as we already know. For $s = 37/9$, the algorithm yields $c_0 = 1$ and $c_1 = (37 - 9)/4 = 7$, and so $37/9 = 1 + 7t$ is a sum of squares of elements of~$S$. Observe that the element $2/3$ appears twice in the table, as the algorithm does not require the fraction $m/9^h$ to be written in lowest terms.
\end{example}



\smallskip
%%%%%%%%%%%%%%%%%%%
\subsection{The Unbreakable Vow: A Bound for the Square Length}

The coefficients computed by the algorithm also yield an explicit bound for the square length of each sum of squares, which only depends on the power of~$9$ in its denominator.

\begin{cor} \label{cor:square length bound}
    Let $s = m/9^h \in \sos S^2$ for some $m,h \in \nn_0$, and let $c_0, \dots, c_h$ be the coefficients computed by the algorithm. Then
    \[
        \ell_S(s) \le \sum_{i=0}^{h-1} c_i + \ell_{\nn_0}(c_h) \le 3h + 4.
    \]
\end{cor}

\begin{proof}
    By Proposition~\ref{prop:algorithm}, the coefficients $c_0, \dots, c_h$ are nonnegative. For each $i \in \ldb 0,h-1 \rdb$, the term $c_i t^i$ is the sum of $c_i$ copies of $(q^i)^2$. On the other hand, by Lagrange's theorem, we can write $c_h = v_1^2 + \dots + v_r^2$, where $v_1, \dots, v_r \in \nn_0$ and $r = \ell_{\nn_0}(c_h) \le 4$. Therefore
    \[
        s = \sum_{i=0}^{h-1} \sum_{j=1}^{c_i} (q^i)^2 + \sum_{j=1}^r (v_j q^h)^2,
    \]
    and all the square roots belong to~$S$, which proves the first inequality. The second inequality follows from the fact that $c_i \le 3$ for every $i \in \ldb 0,h-1 \rdb$.
\end{proof}

Let us compare the bound in Corollary~\ref{cor:square length bound} with the actual square lengths of two elements of~$S$.

\begin{example}
    For $s = 133/81$, Corollary~\ref{cor:square length bound} yields $\ell_S(s) \le 3$, and we know from Example~\ref{ex:two thirds unbounded length} that $\ell_S(s) = 3$. Thus, the bound in Corollary~\ref{cor:square length bound} can be attained. On the other hand, for $s = 37/9$, Corollary~\ref{cor:square length bound} yields $\ell_S(s) \le 1 + \ell_{\nn_0}(7) = 5$, but we will see in Example~\ref{ex:37/9} that $\ell_S(37/9) = 3$.
\end{example}

Observe that Corollary~\ref{cor:square length bound} is compatible with the fact that $p(2/3) = \infty$, as the exponent~$h$ is not bounded as $s$ ranges over $\sos S^2$.



\medskip
%%%%%%%%%%%%%%%%%%%
\subsection{The Weasley Twins: Sums of One or Two Squares}

The bound in Corollary~\ref{cor:square length bound} is not always attained, and so it is natural to ask whether the square length of each element of $\sos S^2$ can be computed. For sums of one or two squares, the answer is yes (and, as Fred and George would say, two are always better than one~\cite{WW96}). We first need a finite test to decide whether a fraction whose denominator is a power of~$3$ belongs to~$S$.

\begin{lemma} \label{lem:membership}
    For all $n,h \in \nn_0$,
    \[
        \frac{n}{3^h} \in S \quad \Longleftrightarrow \quad n \in \langle 2^i 3^{h-i} : i \in \ldb 0,h \rdb \rangle.
    \]
\end{lemma}

\begin{proof}
    For the reverse implication, if $n = \sum_{i=0}^h e_i 2^i 3^{h-i}$ for some $e_0, \dots, e_h \in \nn_0$ then $n/3^h = \sum_{i=0}^h e_i q^i \in S$. For the direct implication, suppose that $n/3^h = f(q)$ for some $f \in \nn_0[X]$. By Lemma~\ref{lem:reduced}, we can assume that $f$ is $q$-reduced, that is, all the coefficients of positive degree of~$f$ belong to $\{0,1,2\}$. Now we can mimic the proof of Proposition~\ref{prop:finite test}: if $d := \deg f > h$ then after clearing denominators and reducing modulo~$3$, we obtain that $3 \mid e_d 2^d$, where $e_d \in \{1,2\}$ is the leading coefficient of~$f$, which is not possible. Hence $\deg f \le h$, and multiplying the equality $n/3^h = f(q)$ by $3^h$ yields the desired membership.
\end{proof}

With Lemma~\ref{lem:membership} in hand, we can decide whether an element of~$S$ is a sum of at most two squares.

\begin{prop} \label{prop:two squares}
    Let $m,h \in \nn_0$, and suppose that $m/9^h = x^2 + y^2$ for some $x,y \in S$. Then $3^h x$ and $3^h y$ are nonnegative integers. As a consequence, one can decide whether $\ell_S(m/9^h) \le 2$ by enumerating all the pairs $(n_1,n_2) \in \nn_0^2$ such that $n_1^2 + n_2^2 = m$ and checking whether $n_1/3^h, n_2/3^h \in S$ using Lemma~\ref{lem:membership}. The same finite search, with $n_2 = 0$, decides whether $\ell_S(m/9^h) \le 1$.
\end{prop}

\begin{proof}
    By part~(1) of Lemma~\ref{lem:basic properties}, we can write $x = n_1/3^D$ and $y = n_2/3^D$ for some $n_1,n_2 \in \nn_0$ and $D \in \nn_0$ with $D \ge h$. Then $n_1^2 + n_2^2 = m 9^{D-h}$. Suppose that $D > h$. Then $n_1^2 + n_2^2 \equiv 0 \pmod 3$. Since every square is congruent to either $0$ or $1$ modulo~$3$, both $n_1$ and $n_2$ must be divisible by~$3$, and so we can write $x = (n_1/3)/3^{D-1}$ and $y = (n_2/3)/3^{D-1}$. Repeating this argument as many times as necessary, we can assume that $D = h$, which means that $3^h x$ and $3^h y$ are nonnegative integers. Hence the pair $(n_1,n_2) = (3^h x, 3^h y)$ satisfies $n_1^2 + n_2^2 = m$, and there are only finitely many such pairs. The rest of the statement follows from Lemma~\ref{lem:membership}.
\end{proof}

We now use Proposition~\ref{prop:two squares} to compute the square length of $37/9$.

\begin{example} \label{ex:37/9}
    We claim that $\ell_S(37/9) = 3$. First, observe that
    \[
        \frac{37}9 = \Big( \frac 89 \Big)^2 + \Big( \frac{10}9 \Big)^2 + \Big( \frac{13}9 \Big)^2,
    \]
    where $8/9 = 2q^2$, $10/9 = q + q^2$, and $13/9 = 1 + q^2$ all belong to~$S$. Therefore $\ell_S(37/9) \le 3$. On the other hand, the only pairs $(n_1,n_2) \in \nn_0^2$ with $n_1^2 + n_2^2 = 37$ are $(1,6)$ and $(6,1)$. Since $1/3 \notin S$ (Example~\ref{ex:1/3 is not in S_2/3}), it follows from Proposition~\ref{prop:two squares} that $37/9$ is not a sum of at most two squares of elements of~$S$. Hence $\ell_S(37/9) = 3$.

    Observe that if we require all the square roots to be fractions with denominator~$3$ then $37/9$ needs four squares. Indeed, by Lemma~\ref{lem:membership}, the numerators of such square roots are at most~$6$ and belong to $\langle 2,3 \rangle$, so they belong to $\{0,2,3,4,5,6\}$. In a representation of $37$ as a sum of three squares of such numerators, reducing modulo~$3$ forces exactly one of the numerators to be nondivisible by~$3$, and then its square must be congruent to $37 \equiv 1$ modulo~$9$. However, the available numerators $2$, $4$, and $5$ have squares congruent to $4$, $7$, and $7$ modulo~$9$, respectively. On the other hand, $37/9 = (5/3)^2 + 3(2/3)^2$, where $5/3 = 1 + q \in S$. Thus, a shortest representation may require larger denominators than the ones appearing in the element we aim to represent.
\end{example}

The phenomenon illustrated in the second part of Example~\ref{ex:37/9} can be much more pronounced, as the following example shows.

\begin{example} \label{ex:17/3}
    We claim that $\ell_S(17/3) = 3$. Since $17/3 = 51/9$ and $51 \equiv 0 \pmod 3$, every pair $(n_1,n_2) \in \nn_0^2$ satisfying $n_1^2 + n_2^2 = 51$ would consist of multiples of~$3$, which would imply that $9 \mid_{\nn_0} 51$. Thus, it follows from Proposition~\ref{prop:two squares} that $\ell_S(17/3) \ge 3$. On the other hand, the equality $66985^2 + 69865^2 + 101933^2 = 17 \cdot 3^{19}$ shows that
    \[
        \frac{17}3 = \Big( \frac{66985}{3^{10}} \Big)^2 + \Big( \frac{69865}{3^{10}} \Big)^2 + \Big( \frac{101933}{3^{10}} \Big)^2,
    \]
    where the three square roots belong to~$S$ because
    \[
        \begin{aligned}
            \frac{66985}{3^{10}} &= 1 + 2q^7 + q^{10}, \\
            \frac{69865}{3^{10}} &= 1 + q^6 + 2q^8 + q^{10}, \\
            \frac{101933}{3^{10}} &= 1 + q^2 + 2q^7 + 2q^8 + 2q^9 + 2q^{10}.
        \end{aligned}
    \]
    Hence $\ell_S(17/3) = 3$. Furthermore, an exhaustive computer search (using Lemma~\ref{lem:membership} to enumerate all the candidate square roots) shows that $17/3$ cannot be written as a sum of three squares of elements of~$S$ whose denominators divide $3^9$. Thus, every shortest representation of $17/3$ requires a square root whose denominator is at least $3^{10}$, even though $17/3$ only has denominator~$3$.
\end{example}



\medskip
%%%%%%%%%%%%%%%%%%%
\subsection{Divination: Open Questions}

Even without the help of~\cite{cV51}, it is not hard to foresee which questions arise next. For the semidomain $S = \nn_0[2/3]$, we have seen how to decide whether an element is a sum of squares (Proposition~\ref{prop:algorithm}), how to bound its square length (Corollary~\ref{cor:square length bound}), and how to decide whether its square length is at most~$2$ (Proposition~\ref{prop:two squares}). However, we have not been able to compute the square length of every element of $\sos S^2$. Given $s \in \sos S^2$ and a bound $D \in \nn_0$, Lemma~\ref{lem:membership} allows us to find, by a finite search, the shortest representations of~$s$ whose square roots have denominators dividing $3^D$. Therefore it would suffice to bound, in terms of~$s$, the denominators of the square roots in some shortest representation of~$s$. Proposition~\ref{prop:two squares} provides such a bound for one or two squares, while Example~\ref{ex:17/3} shows that, already for three squares, the required denominators can be much larger than the denominator of~$s$. Hence the following question remains open for us.

\begin{question} \label{q:square length}
    Is there an algorithm that, for each $s \in \sos S^2$, computes the square length $\ell_S(s)$ in the semidomain $S = \nn_0[2/3]$?
\end{question}

Our proof of Proposition~\ref{prop:sos semiring} relies on the identity $3q^2 = 2q$, which is very special to the generator $q = 2/3$. Thus, the following more general question remains open for us as well.

\begin{question} \label{q:general}
    Let $q \in \qq_{>0}$ such that $\mathsf{n}(q) > 1$ and $\mathsf{d}(q) > 1$. Is there an algorithm that, for each $f \in \nn_0[X]$, decides whether $f(q) \in \sos S_q^2$? What can be said about the semidomain $\nn_0[\alpha]$, where $\alpha$ is a positive algebraic number (see~\cite{CMG22})?
\end{question}









\bigskip
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
\section*{Acknowledgments}

We kindly thank Dr.\ Rubeus Hagrid and Prof.\ Remus Lupin for their constant and invaluable guidance during the preparation of this paper. We also thank Prof.\ Severus Snape from Slytherin House for suggesting Example~\ref{ex:Snape}, Prof.\ Minerva McGonagall for asking us the question that led to Example~\ref{ex:37/9}, and Luna Lovegood from Ravenclaw House for independently double-checking the computations in Table~\ref{tab:algorithm} and Example~\ref{ex:17/3}. Finally, we are grateful to the Hogwarts School of Witchcraft and Wizardry for making this magical research experience possible.









\bigskip
%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%
\begin{thebibliography}{99}

    \bibitem{ABP21} S. Albizu-Campos, J. Bringas, and H. Polo, \emph{On the atomic structure of exponential Puiseux monoids and semirings}, Comm. Algebra \textbf{49} (2021) 850--863.

    \bibitem{bB79} B. Babbling, \emph{Ancient Runes Made Easy}, Flourish and Blotts, Diagon Alley, London, 1979.

    \bibitem{bB47} B. Bagshot, \emph{A History of Magic}, Little Red Books, Godric's Hollow, 1947.

    \bibitem{BM24} B.~C. Berndt and P. Moree, \emph{Sums of two squares and the tau-function: Ramanujan's trail}, preprint (2024). Available on arXiv: \url{https://arxiv.org/abs/2409.03428}

    \bibitem{CGG20} S.~T. Chapman, F. Gotti, and M. Gotti, \emph{Factorization invariants of Puiseux monoids generated by geometric sequences}, Comm. Algebra \textbf{48} (2020) 380--396.

    \bibitem{CDLR82} M.~D. Choi, Z.~D. Dai, T.~Y. Lam, and B. Reznick, \emph{The Pythagoras number of some affine algebras and local algebras}, J. Reine Angew. Math. \textbf{336} (1982) 45--82.

    \bibitem{CMG22} J. Correa-Morris and F. Gotti, \emph{On the additive structure of algebraic valuations of polynomial semirings}, J. Pure Appl. Algebra \textbf{226} (2022) 107104.

    \bibitem{aD62} A. Dumbledore, \emph{A Transfiguration Primer: From Matchsticks to Every Flavour Beans}, Obscurus Books, London, 1962.

    \bibitem{jG99} J.~S. Golan, \emph{Semirings and their Applications}, Kluwer Academic Publishers, Dordrecht, 1999.

    \bibitem{mG65} M. Goshawk, \emph{The Standard Book of Spells (Grade~1)}, Obscurus Books, London, 1965.

    \bibitem{GP23} F. Gotti and H. Polo, \emph{On the arithmetic of polynomial semidomains}, Forum Math. \textbf{35} (2023) 1179--1197.

    \bibitem{HW08} G.~H. Hardy and E.~M. Wright, \emph{An Introduction to the Theory of Numbers}, 6th edition (revised by D.~R. Heath-Brown and J.~H. Silverman), Oxford University Press, Oxford, 2008.

    \bibitem{xL95} X. Lovegood, \emph{Two thirds is a sum of three squares!}, The Quibbler \textbf{12} (1995) 4--5.

    \bibitem{mN96} M.~B. Nathanson, \emph{Additive Number Theory: The Classical Bases}, Graduate Texts in Mathematics Vol. 164, Springer-Verlag, New York, 1996.

    \bibitem{gO80} G. Ollivander, \emph{Measuring Wands: Length, Flexibility, and Core}, Ollivanders: Makers of Fine Wands since 382 B.C., Diagon Alley, London, 1980.

    \bibitem{jR98} J.~K. Rowling, \emph{Harry Potter and the Sorcerer's Stone}, Arthur A. Levine Books, New York, 1998.

    \bibitem{jR05} J.~K. Rowling, \emph{Harry Potter and the Half-Blood Prince}, Arthur A. Levine Books, New York, 2005.

    \bibitem{nS27} N. Scamander, \emph{Fantastic Beasts and Where to Find Them}, Obscurus Books, London, 1927.

    \bibitem{cV51} C. Vablatsky, \emph{Unfogging the Future}, Flourish and Blotts, Diagon Alley, London, 1951.

    \bibitem{sV97} S. Vector, \emph{On the arithmancy of sums of squares}, J. Hogwarts Arithmancy \textbf{7} (1997) 1--17.

    \bibitem{aW52} A. Waffling, \emph{Magical Theory}, Obscurus Books, London, 1952.

    \bibitem{WW96} F. Weasley and G. Weasley, \emph{Weasleys' Wizard Wheezes: Product Catalogue}, 93 Diagon Alley, London, 1996.

\end{thebibliography}
\bigskip

\end{document}

Page 1 of the sample paper

Page 2 of the sample paper

Page 3 of the sample paper

Page 4 of the sample paper

Page 5 of the sample paper

Page 6 of the sample paper

Page 7 of the sample paper

Page 8 of the sample paper

Page 9 of the sample paper

Page 10 of the sample paper

Page 11 of the sample paper

Page 12 of the sample paper

Page 13 of the sample paper

Page 14 of the sample paper

Page 15 of the sample paper

Page 16 of the sample paper

Page 17 of the sample paper

Page 18 of the sample paper

Page 19 of the sample paper

Page 20 of the sample paper