On periodic sequences for algebraic numbers

Abstract: For each positive integer n greater than or equal to 2, a new approach to expressing real numbers as sequences of nonnegative integers is given. The n=2 case is equivalent to the standard continued fraction algorithm. For n=3, it reduces to a new iteration of the triangle. Cubic irrationals that are roots of x^3 + k x^2 + x - 1 are shown to be precisely those numbers with purely periodic expansions of period length one. For general positive integers n, it reduces to a new iteration of an n dimensional simplex.

\section{Introduction}

In 1848 Hermite \cite{Herm} posed to Jacobi the problem of
generalizing continued fractions so that periodic expansions of a
number reflect its algebraic properties.  We state this as:

\noindent{\bf The Hermite Problem}: {\it Find methods for writing
	numbers that reflect special algebraic properties.}

\noindent	In attempting to answer this question, Jacobi developed a special case
	of what is now called the Jacobi-Perron algorithm.
	Bernstein \cite{Bernstein} wrote a good survey of this algorithm;
	Schweiger
   \cite{Schweiger} covered its ergodic properties. Brentjes' book \cite{Brentjes} is
  a good source for its many variations. Using quite different methods,
  Minkowski  \cite{Minkowski 1899}  developed a quite different
  approach to the
	 Hermite's problem. For another attempt, see the work of Ferguson
	 and Forcade
	 \cite{Ferguson-Forcade}.

In this paper we give another approach,
which will also be a  generalization of continued fractions.
  To each $n$-tuple of real numbers
 $(\alpha_{1}, \ldots ,\alpha_{n})$,
 with $1 \geq \alpha_{1} \geq  \ldots \geq \alpha_{n}$, we
  will associate  a sequence
 of nonnegative integers.  For reasons that will become apparent later, we
 will call this sequence the {\it triangle sequence} (or {\it simplex
 sequence}) for the $n$-tuple. The hope is that the periodicity of
 this sequence will provide insight into whether or not
  the $\alpha_{k}$ are algebraic of degree at most $n$.  We will show
  that this is the case for when $n=3$.

In the next section we quickly review some well-known facts about
 continued fractions.  We then concentrate on the cubic case, for
 ease of exposition.  The proofs go over easily to the general case,
 which we will discuss in  section nine.  In section three we define,
 given a pair $(\alpha, \beta) \in \{ (x,y): 1 \geq x \geq y \geq 0 \}$,
  the triangle
 iteration and the triangle sequence.  Section four will recast the
 triangle sequence via matrices.  This will allow us to interpret the
 triangle sequence as a method  for producing integer lattice points
 that approach the
 plane $x + \alpha y + \beta z=0$.  Section five will show that
 nonterminating triangle sequences  uniquely determine the pair $(\alpha,
 \beta)$.  Section six discusses how  every possible triangle
 sequence corresponds to
  a pair $(\alpha, \beta) \in \{ (x,y): 1 \geq x \geq y \geq 0 \}.$
  Section seven turns to classifying those pairs with purely periodic
  sequences.  Section eight concerns itself with periodicity in
  general.  Section nine deals with the general case $n$.

  At http://www.williams.edu/Mathematics/tgarrity/triangle.html,
  there is a web page that gives many examples of triangle sequences
  and provides software packages running on Mathematica for making
  actual computations.

I would like to thank Edward Burger for many helpful discussions.
Tegan Cheslack-Postava, Alexander
Diesl, Matthew Lepinski and  Adam Schuyler  have provided critical aid.
 I
would also like to thank K. M. Briggs for useful comments on an
earlier version of this paper.
 \section{Continued Fractions}
 Given a real number $\alpha$, recall that its continued fraction
 expansion is:
 $$	 \alpha  = a_{0} + {1\over {a_{1}  + {1\over a_{2}  + ...}}},$$
where
$		a _{0} = \{ \alpha \} = \mbox{greatest integer part of}\; \alpha$,
$$a_{1} = \{ {1\over \alpha  - a_{0}} \}\; \mbox{ and}\;
		b_{1} =  {1\over \alpha  - a_{0}} - a_{1}.$$
Inductively, define
$$		a_{k} = \{{1\over b_{k-1}}\} \;
\mbox{and}\;
b_{k} = {1\over b_{k-1}} - 	a_{k}.$$
A number's continued fraction expansion can be captured by
examining iterations of the Gauss map $G:I \rightarrow I$, with $I$ denoting
the unit interval $(0,1]$, defined by
$$G(x) = {1\over x} - \{{1\over x}\}.$$
If we partition the unit interval into a disjoint union of
subintervals:
$$I_{k} = \{ x \in I: \frac{1}{k+1} < x \leq \frac{1}{k} \},$$
then the nonnegative integers $a_{k}$ in the continued fraction
expansion of $\alpha$ can be interpreted as keeping track of which
subinterval the number $\alpha$ maps into under the kth iterate of $G$.
Namely,  $G^{k}(\alpha)\in I_{a_{k}}$.

\section{The Triangle Iteration}
In this section we define an iteration $T$ on the triangle
$$ \bigtriangleup = \{ (x,y): 1 \geq x \geq y >  0 \}.$$
Partition this triangle into disjoint triangles
$$\bigtriangleup_{k} = \{ (x,y) \in \bigtriangleup: 1 - x - ky
\geq 0 > 1 - x - (k+1)y \},$$
where $k$ can be any nonnegative integer. Note that its vertices are
$(1,0)$, $(\frac{1}{k+1},\frac{1}{k+1})$ and $(\frac{1}{k+2},\frac{1}{k+2})$.

 Define the {\it triangle map}
 $T:\bigtriangleup \rightarrow \bigtriangleup \cup \{ (x,0): 0 \leq
 x\leq 1 \}$ by
setting
$$T(\alpha,\beta) = (\frac{\beta}{\alpha}, \frac{1 - \alpha - k
\beta}{\alpha}),$$
if the pair $(\alpha,\beta) \in \bigtriangleup_{k}$. Frequently we
will abuse notation by denoting $\bigtriangleup \cup \{ (x,0): 0 \leq
 x\leq 1 \}$ by  $\bigtriangleup$.

We want to associate a sequence of nonnegative integers to the
iterates of the map $T$.  Basically, if $T^{k}(\alpha,\beta) \in
 \bigtriangleup_{a_{k}}$, we will associate to $(\alpha, \beta)$
 the sequence $(a_{1}, \ldots)$.

Recursively define a sequence of decreasing positive reals and a sequence of
nonnegative integers as follows:
Set $d_{-2}= 1, d_{-1} = \alpha, d_{0}=\beta.$ Assuming that we have
$d_{k-3} > d_{k-2}> d_{k-1}>0$, define $a_{k}$ to be a nonnegative
integer such that
$$d_{k-3} -d_{k-2} - a_{k} d_{k-1} \geq 0$$
but
$$d_{k-3} -d_{k-2} - (a_{k} + 1) d_{k-1} < 0.$$
Then set
$$d_{k} = d_{k-3} -d_{k-2} - a_{k} d_{k-1}.$$
If at any stage $d_{k}=0$, stop.

\begin{definition}
The triangle sequence of the pair $(\alpha, \beta)$ is the sequence
$(a_{1}, \ldots)$.
\end{definition}
We will say that the triangle sequence {\it terminates} if at any
stage $d_{k}=0$.  In these cases, the triangle sequence will be
finite.

Note that
$$T(\frac{d_{k-1}}{d_{k-2}}, \frac{d_{k}}{d_{k-2}})
= (\frac{d_{k}}{d_{k-1}}, \frac{d_{k+1}}{d_{k-1}}).$$

Also note that by comparing this to the first part of chapter seven
in \cite{Stark}, we see that this is indeed a generalization of
continued fractions.

\section{The Triangle Iteration via Matrices and Integer Lattice
Points}

Let $(a_{1}, \ldots)$ be a triangle sequence associated to the
pair $(\alpha, \beta)$.  Set
$$P_{k} = \pmatrix{0&0&1\cr 1&0&-1 \cr 0&1&-a_{k}\cr}.$$
Note that $\det P_{k} =  1$.
Set $M_{k} = P_{1}\cdot P_{2} \cdots P_{k}$. This allows us to
translate the fact that
$$T(\frac{d_{k-1}}{d_{k-2}}, \frac{d_{k}}{d_{k-2}})
= (\frac{d_{k}}{d_{k-1}}, \frac{d_{k+1}}{d_{k-1}})$$
 into the language
of matrices via the following proposition (whose proof is
straightforward):
\begin{prop}
Given the pair $(\alpha, \beta)$, we have
$$(d_{k-2}, d_{k-1}, d_{k}) = (1, \alpha, \beta)M_{k}.$$
\end{prop}
 Write
$$M_{k} = \pmatrix{p_{k-2}&p_{k-1}&p_{k}\cr q_{k-2}&q_{k-1}&q_{k}
 \cr r_{k-2}&r_{k-1}&r_{k}\cr}.$$
 Then a calculation leads to:
 \begin{prop}
 For all $k$, we have
 $$p_{k} = p_{k-3} - p_{k-2} - a_{k}p_{k-1},$$
 $$q_{k} = q_{k-3} - q_{k-2} - a_{k}q_{k-1},$$
and
 $$r_{k} = r_{k-3} - r_{k-2} - a_{k}r_{k-1}.$$
\end{prop}

Set
$$C_{k} = \pmatrix{p_{k}\cr q_{k}
 \cr r_{k}\cr}.$$
 Note that $C_{k}$ can be viewed as a vector in the integer lattice.
Then the numbers $d_{k}$ are seen to be a measure of the distance from the
 plane $x + \alpha y + \beta z = 0$ to the lattice point $C_{k}$,
 since $d_{k} = (1, \alpha, \beta)C_{k}.$  Observing that
 $$C_{k}= C_{k-3} - C_{k-2} - a_{k}C_{k-1},$$
 we see thus that the triangle sequence encodes information of how to get a
 sequence of lattice points to approach the plane $x + \alpha y + \beta
 z = 0$, in direct analogue to continued fractions \cite{Stark}.
Unlike the continued fraction case, though, these lattice points need
not be the best such approximations.

\section{Arbitrary triangle sequences}

\begin{theorem}
Let $(k_{1}, k_{2},
\ldots )$ be any infinite sequence of nonnegative integers with
infinitely many of the $k_{i}$ not zero.  Then there is a  pair
$(\alpha, \beta)$ in $\bigtriangleup$ that has this sequence as its
triangle sequence.
\end{theorem}

\noindent {\bf Proof:}
Suppose that we have an infinite triangle sequence $(k_{1}, k_{2},
\ldots )$.
By a straighforward calculation,we see that a line with
equations $y=mx+b$ will map to the line
$$(1-k b)u - (1- k b)m = bv + bkm + b,$$
where $T(x,y) = (u,v).$

The map $T$, restricted to the triangle $\bigtriangleup_{k}$,
 will send  the vertices of
$\bigtriangleup_{k}$ to the vertices of $\bigtriangleup$, with
$T(1,0) = (0,0)$, $T(\frac{1}{k+1}, \frac{1}{k+1})= (1,0)$
and  $T(\frac{1}{k+2}, \frac{1}{k+2})= (1,1)$.
 Restricted to $\bigtriangleup_{k}$, the map $T$ is thus one-to-one and
 onto $\bigtriangleup$.

 But this gives us our theorem, as each $\bigtriangleup_{k}$
 can be split into its own (smaller) triangles, one for each
 nonnegative integer, and hence each of these smaller triangles can be
 split into even smaller triangles, etc. Hence to each nonterminating
 triangle sequence there corresponds a pair $(\alpha, \beta)$.
 \noindent {\bf QED}

 \section{Recovering points from the triangle sequence}

 The question of when a triangle sequence determines a
 unique pair $(\alpha, \beta)$ is subtle.  If the sequence
 terminates, then  the pair $(\alpha, \beta)$ is not unique.
 Even if the triangle sequence does not terminate, we do not
 necessarily have uniqueness, as discussed in \cite{CDGLS}.
 But we do have
 \begin{theorem}
 If an integer $k$ occurs infinitely often in a
    nonterminating  sequence $(k_{1}, k_{2},
\ldots )$ of nonnegative integers, then
 there is a unique pair $(\alpha, \beta)$ in $\bigtriangleup$
that has this sequence as its triangle sequence.
\end{theorem}
The proof is contained in \cite{CDGLS} and is not easy.

 If the triangle sequence uniquely determines a pair $(\alpha, \beta)$,
 then we can recover $(\alpha, \beta)$ as follows.
  By construction, the numbers $d_{k}$  approach
 zero.  Consider the plane
 $$x + \alpha y + \beta z = 0,$$
 whose normal vector is $(1, \alpha, \beta)$.  As seen in the last section,
  the columns of the
 matrices $M_{k}$ can be interpreted as vectors that are approaching
 this plane. This will allow us to prove:
 \begin{theorem}
 If a triangle sequence uniquely determines  the pair $(\alpha, \beta)$, then
 $$\alpha = \lim_{k\rightarrow \infty} \frac{p_{k}r_{k-1} -
 p_{k-1}r_{k}}{q_{k-1}r_{k}-q_{k}r_{k-1}}$$
 and
 $$\beta = \lim_{k\rightarrow \infty}\frac{p_{k-1}q_{k} -
 p_{k}q_{k-1}}{q_{k-1}r_{k}-q_{k}r_{k-1}}.$$
 \end{theorem}
 The proof is also in \cite{CDGLS}.  The quick, but incorrect, argument is
 that
  the vectors $(p_{k-1},q_{k-1},r_{k-1})$ and
 $(p_{k},q_{k},r_{k})$ are columns in the matrix $M_{k}$, each
 of which  approaches being in the plane  $x + \alpha y + \beta z =
 0$.  Thus the limit as $k$ approaches infinity of the
 cross product of these two vectors must point in the
 normal direction  $(1, \alpha, \beta)$.  But this is the above limits.

\section{Purely periodic triangle sequences of period length one}
\begin{theorem}
Let $0 < \beta \leq \alpha < 1$ be a pair of numbers whose triangle
sequence is $(k,k,k,\ldots)$.  Then $ \beta = \alpha^{2}$ and $\alpha$
is a root of the cubic equation
$$x^{3} + k x^{2} + x -1 = 0.$$
Further if $\alpha$ is the real root of this cubic that is between
zero and one, then
$(\alpha, \alpha^{2})$ has purely periodic triangle sequence $(k,k,k,
\ldots)$.
\end{theorem}
\noindent {\bf Proof:} We need $T(\alpha,\beta) = (\alpha,\beta)$. Since $T(\alpha,\beta)=
 (\frac{\beta}{\alpha}, \frac{1-\alpha - k \beta}{\alpha})$, we need
 $$\alpha = \frac{\beta}{\alpha}$$
 and
 $$\beta = \frac{1-\alpha - k \beta}{\alpha}.$$
 From the first equation we get $\beta = \alpha^{2}$.  Plugging in
 $\alpha^{2}$ for $\beta$ in the second equation and clearing
 denominators leads to
 $$\alpha^{3} + k\alpha^{2} + \alpha -1 = 0$$
 and the first part of the theorem.

 Now for the converse.  Since the polynomial $x^{3} + k x^{2} + x -1 $
 is $-1$ at $x=0$ and is positive at $x=1$, there is root $\alpha$
 between zero and one.  We must show that $(\alpha, \alpha^{2})$ is
 in $\bigtriangleup_{k}$ and that $T(\alpha, \alpha^{2}) = (\alpha, \alpha^{2})$.
We know that
$$\alpha^{3} = 1 - \alpha - k \alpha^{2}.$$
Since $\alpha^{3}>0$, we have $1 - \alpha - k \alpha^{2} > 0$.
Now
$$ 1 - \alpha - (k+1) \alpha^{2} = \alpha^{3} - \alpha^{2} < 0,$$
which shows that $(\alpha, \alpha^{2}) \in \bigtriangleup_{k}$.

Finally,
$$T(\alpha, \alpha^{2}) = (\frac{\alpha^{2}}{\alpha},
\frac{1-\alpha - k \alpha^{2}}{\alpha})$$
$$= (\alpha, \alpha^{2}).$$

\noindent {\bf QED}

Similar formulas for purely periodic sequences with period
length two, three, etc., can be computed, but they quickly
become computationally
messy.

 \section{Terminating and Periodic Triangle Sequences}

 We first want to show that if $(\alpha, \beta)$ is a pair of rational
 numbers, then the corresponding triangle sequence must terminate,
 meaning that eventually all of the $k_{n}$ will be zero.
 \begin{theorem}
 Let $(\alpha, \beta)$ be a pair of rational numbers in
 $\bigtriangleup$.  Then the corresponding triangle sequence terminates.
 \end{theorem}

 \noindent {\bf Proof:}
 In constructing the triangle sequence, we are
 just concerned with the ratios of the triple $(1, \alpha, \beta)$.
 By clearing denominators, we can replace this triple by a triple of
 positive integers $(p,q,r)$, with $p \geq q \geq r$. Then we have
 $d_{-2} = p, d_{-1}=q, d_{0}=r$.  Then the sequence of $d_{k}$ will
 be a sequence of positive decreasing integers.  Thus for some $k$ we
 must have $d_{k}=0$, forcing the triangle sequence to terminate.

\noindent {\bf QED}

 Now to see what happens when the triangle sequence is eventually
 periodic.
 \begin{theorem}
 Let $(\alpha, \beta)$ be a pair of real numbers in
 $\bigtriangleup$ whose triangle sequence is eventually periodic.
 Then $\alpha$ and  $\beta$ have degree at most three,  with
 $\alpha \in {\bf Q}[\beta]$ or $\beta \in {\bf Q}[\alpha]$.
 \end{theorem}

 \noindent {\bf Proof:} If both $\alpha$ and $\beta$ are
 rational, then by the above theorem the triangle sequence
 terminates.  Thus we assume that not both $\alpha$ and and $\beta$
 are rational.  Since the triangle sequence is periodic, there will be
 an integer appearing infinitely often in this sequence, which means
 that the sequence will uniquely determine a pair $(\alpha, \beta)$.

 If the triangle sequence is periodic, there must be
 an $n$ and $m$ so that
 $$(\frac{d_{n-2}}{d_{n}}, \frac{d_{n-1}}{d_{n}})=
 (\frac{d_{m-2}}{d_{m}},\frac{d_{m-1}}{d_{m}}).$$
 Thus there exists a number $\lambda$ with
 $$(d_{n-2},d_{n-1},d_{n})= \lambda (d_{m-2},d_{m-1},d_{m}).$$
 Using matrices we have:
 $$(1, \alpha, \beta)M_{n} = \lambda (1, \alpha, \beta)M_{m}$$
 and thus
 $$(1, \alpha, \beta)M_{n} M_{m}^{-1} = \lambda (1, \alpha, \beta).$$
  Since  $M_{n}$ and $M_{m}$ have integer
   coefficients, the matrix $M_{n} M_{m}^{-1}$ will have rational
   coefficients.  Since the $d_{k}$ are decreasing, we must have
   $|\lambda| \neq 1$. Since both $M_{n}$ and $M_{m}$ have
   determinant  one, we have that $M_{n} M_{m}^{-1}$
   cannot be a multiple of the identity matrix.

   Set
   $$M_{n} M_{m}^{-1}= \pmatrix{q_{11}&q_{12}&q_{13}\cr
   q_{21}&q_{22}&q_{23}
 \cr q_{31}&q_{32}&q_{33}\cr}.$$
Then
$$q_{11} + q_{21}\alpha + q_{31} \beta = \lambda$$
$$q_{12} + q_{22}\alpha + q_{32} \beta = \lambda \alpha$$
and
$$q_{13} + q_{23}\alpha + q_{33} \beta = \lambda \beta.$$
We can eliminate the unknown $\lambda$ from the first and second equations
and then from the first and third equations, leaving two equations
with unknowns $\alpha$ and $\beta$.  Using these two equations we can
eliminate one of the remaining variables, leaving the last as the
solution to  polynomial with rational coefficients.  If this
polynomial is the zero polynomial, then it can be seen that this will
force $M_{n} M_{m}^{-1}$ to be a multiple of the identity, which is
not possible.  Finally, it can be checked
that this polynomial is a cubic.

\noindent {\bf QED}

\section{The higher degree case}

Almost all of this goes over in higher dimensions.
We just replace our triangle by a dimension
$n$ simplex.  The notation, though, is more cumbersome.

 Set
$$ \bigtriangleup = \{ (x_{1},\ldots ,x_{n}): 1 \geq x_{1} \geq \ldots
 \geq x_{n} > 0 \}.$$
 As we did before, we will frequently also call
 $ \bigtriangleup = \{ (x_{1},\ldots ,x_{n}): 1 \geq x_{1} \geq \ldots
 \geq x_{n} \geq 0 \}.$
Set
$$\bigtriangleup_{k} = \{ (x_{1},\ldots ,x_{n})
 \in \bigtriangleup: 1 - x_{1} - \ldots  - x_{n-1} -  kx_{n}
\geq 0 > 1 - x_{1} - \ldots  - x_{n-1} -  (k+1)x_{n}\},$$
where $k$ can be any nonnegative integer.  These are the direct
analogue of the triangles $\bigtriangleup_{k}$ in the first part of
this paper.  Unlike the earlier case, these $\bigtriangleup_{k}$,
while disjoint, do not partition the simplex $\bigtriangleup$.  To
partition $\bigtriangleup$, we need more simplices.
Set
$$\bigtriangleup ' = \{ (x_{1},\ldots ,x_{n})
 \in \bigtriangleup: 0 > 1 - x_{1} - \ldots  - x_{n}
\}.$$
Then set
$$\bigtriangleup_{ij} = \{ (x_{1},\ldots ,x_{n})
 \in \bigtriangleup ': x_{j} \geq 1 - x_{1} - \ldots  - x_{i}
\geq x_{j+1} \},$$
where $ 1 \leq i \leq n-2$ and $i < j \leq n$.  Also, we use the
convention that $x_{n+1}$ is identically zero.
\begin{lemma}
The $\bigtriangleup_{k}$ and $\bigtriangleup_{ij}$ form a simplicial
decomposition of the simplex $\bigtriangleup$.
\end{lemma}

\noindent {\bf Proof:}  It can be directly checked that the
$\bigtriangleup_{k}$ and $\bigtriangleup_{ij}$ do form a disjoint
partition of $\bigtriangleup$.  We need to show
 that the $\bigtriangleup_{k}$ and $\bigtriangleup_{ij}$
are simplices. Thus we want to show that each of these polygons have
exactly $n+1$ vertices.  Label the $n+1$
vertices of the simplex $\bigtriangleup$ by $v_{0} = (0,\ldots, 0),
v_{1}=(1,0,\ldots, 0), v_{2}=(1,1,0,\ldots, 0), \ldots,
v_{n}=(1,\ldots,1)$.  We label each of the $\frac{n(n+1)}{2}$ edges
 of the simplex by $v_{i}v_{j}$ if the endpoints of the edge are the
 vertices $v_{i}$ and $v_{j}$. Consider
the set  $\bigtriangleup_{k}$.   The hyperplanes
$$x_{1}+\ldots+ x_{n-1} + k x_{n} = 1$$
and
$$x_{1}+\ldots+ x_{n-1} + (k+1) x_{n} = 1$$
form two of the faces.  These hyperplanes intersect  each edge
$v_{0}v_{l}$, with $l < n$, in the same point $(\frac{1}{l}, \ldots,
\frac{1}{l}, 0, \ldots,0)$, where this $n$-tuple has its first $l$
terms $\frac{1}{l}$ and the rest zero. The hyperplanes intersect the
edge $v_{0}v_{n}$ in two distinct points: $x_{1}+\ldots+ x_{n-1} + k x_{n} = 1$
intersects at the point $(\frac{1}{n+k-1},\ldots,\frac{1}{n+k-1})$
while $x_{1}+\ldots+ x_{n-1} + (k+1) x_{n} = 1$ intersects in the point
$(\frac{1}{n+k},\ldots,\frac{1}{n+k})$. Since both hyperplanes contain the
vertex $v_{1}$, both intersect all of the edges $v_{1}v_{l}$ exactly
at $v_{1}$.  Both hyperplanes will miss all of the other edges
$v_{i}v_{j}$, with $i,j \geq 2$, since for every point on all of these
edges,
$x_{1}=1$, $x_{2}=1$ and  $x_{l}\geq 0$, forcing the intersections to
be empty.  But now we just have to count and see that the number of
vertices is indeed $n+1$.  Thus $\bigtriangleup_{k}$ is a simplex.

The argument is similar for $\bigtriangleup_{ij}$.  Here we look at the
hyperplanes
$$x_{1}+\ldots+ x_{i} +  x_{j} = 1$$
and
$$x_{1}+\ldots+ x_{n-1} +  x_{j+1} = 1.$$
Both will intersect each of the edges $v_{0}v_{l}$, for $l\neq j$, in the
same point, will intersect the edges  $v_{1}v_{l}$ exactly
at $v_{1}$ and will miss the edges $v_{i}v_{j}$, with $i,j \geq 2$.
 They will intersect the edge $v_{0}v_{j}$ at distinct
points.  Then $\bigtriangleup_{ij}$ has $n+1$ distinct
vertices and is thus a simplex.

\noindent{\bf QED}

 Define the {\it n-triangle map}
 $T:\bigtriangleup \rightarrow \bigtriangleup $ by
setting
$$T(\alpha_{1}, \ldots, \alpha_{n}) =
 (\frac{\alpha_{2}}{\alpha_{1}}, \ldots,
 \frac{\alpha_{n-1}}{\alpha_{1}}, \frac{1 - \alpha_{1} \ldots
 -\alpha_{n-1} - k
\alpha_{n}}{\alpha_{1}}),$$
if  $(\alpha_{1}, \ldots, \alpha_{n}) \in \bigtriangleup_{k}$ and by
$$T(\alpha_{1}, \ldots, \alpha_{n}) =
 (\frac{\alpha_{2}}{\alpha_{1}}, \ldots,
 \frac{\alpha_{j}}{\alpha_{1}}, \frac{1 - \alpha_{1} \ldots
 -\alpha_{i}}{\alpha_{1}}, \frac{\alpha_{j+1}}{\alpha_{1}}, \ldots,
 \frac{\alpha_{n}}{\alpha_{1}}),$$
if  $(\alpha_{1}, \ldots, \alpha_{n}) \in \bigtriangleup_{ij}$.

By direct calculation, we
see that $T(\alpha_{1}, \ldots, \alpha_{n})\in\bigtriangleup$.
Further,  each of the restriction maps
 $T:\bigtriangleup_{k} \rightarrow \bigtriangleup$ and
  $T:\bigtriangleup_{ij} \rightarrow \bigtriangleup$  are
one-to-one and onto, since the vertices of $\bigtriangleup_{k}$ and
$\bigtriangleup_{ij}$
 map
to the vertices of $\bigtriangleup$ and since lines map to lines.

We want to associate to each    $(\alpha_{1}, \ldots, \alpha_{n})$
in $\bigtriangleup$ an infinite sequence $(a_{0}, a_{1}, \ldots)$,
where each $a_{k}$ is either a non-negative integer or a symbol
$(ij)$, where $1\leq i \leq n-2$ and $i < j \leq n$.  If
$T^{k}(\alpha_{1}, \ldots, \alpha_{n}) \in
 \bigtriangleup_{l}$, set $a_{k} = l$ and
  if $T^{k}(\alpha_{1}, \ldots, \alpha_{n}) \in
 \bigtriangleup_{ij}$, set $a_{k} = (ij)$.  Finally, if the $n$th
 term for $T^{k}(\alpha_{1}, \ldots, \alpha_{n})$ is zero, stop.
 \begin{definition}
The n-triangle sequence  of  $(\alpha_{1}, \ldots, \alpha_{n})$ is the sequence
$(a_{1}, \ldots)$.
\end{definition}

We can also recursively define the triangle sequence as follows.  We
want to define a sequence of $(n+1)$-tuples of nonincreasing positive
numbers.  We will denote this sequence by $d_{1}(k),\ldots,
d_{n+1}(k)$, for $k\geq 0$. Start with
$$d_{1}(0) = 1, d_{2}(0) =
\alpha_{1},\ldots,
d_{n+1}(0)= \alpha_{n}.$$  Assume we have $d_{1}(k-1),\ldots,
d_{n+1}(k-1)$. Define the symbol $a_{k}$ as follows.   If there is a
nonnegative integer $l$ such that
$$d_{1}(k-1) - d_{2}(k-1) - \ldots - d_{n}(k-1)
 - l d_{n+1}(k-1) \geq 0$$
 but
$$d_{1}(k-1) - d_{2}(k-1) - \ldots - d_{n}(k-1)
 - (l+1) d_{n+1}(k-1) < 0,$$
 set
$a_{k}= l$ and define
$$d_{1}(k) = d_{2}(k-1), \ldots, d_{n}(k) = d_{n+1}(k-1)$$
and
$$d_{n+1}(k) = d_{1}(k-1) - d_{2}(k-1) - \ldots - d_{n}(k-1)
 - l d_{n+1}(k-1).$$
 If no such integer exists, then there is a pair $(ij)$, with $1\leq
 i \leq n-1$ and $i < j\leq n+1$ such that
 $$d_{j}(k-1) \geq d_{1}(k-1) - d_{2}(k-1) - \ldots - d_{i}(k-1)
> d_{j+1}(k-1).$$
In this case, define $a_{k}= (ij)$ and set
$$d_{1}(k) = d_{2}(k-1), \ldots, d_{j-1}(k) = d_{j}(k-1),$$
$$d_{j}(k) = d_{1}(k-1) - d_{2}(k-1) - \ldots - d_{i}(k-1)$$
and
$$d_{j+1}(k) = d_{j+1}(k-1), \ldots, d_{n+1}(k) = d_{n+1}(k-1).$$

Now for the matrix version.  Let $(a_{1}, \ldots)$ be an
n-triangle sequence for $(\alpha_{1}, \ldots, \alpha_{n})$.  If
$a_{k}$ is a nonnegative integer, let
$P_{k}$ be the $(n+1)\times (n+1)$

$$ \pmatrix{0& 0&  \dots & 0 &1\cr 1 & 0 & \dots & 0 &-1 \cr \; & \;\vdots
 & \; & \; \cr 0 & \ldots & 1 & 0 & -1 \cr
0 & \dots &  0  & 1 &-a_{k}\cr}.$$

If $a_{k}$ is the pair $(ij)$, let $P_{k}$ be the $(n+1)\times (n+1)$
matrix defined by:
$$(x_{1}, \ldots, x_{n+1})P_{k} =(x_{2},\ldots x_{j}, x_{1}-x_{2}
-\ldots - x_{i}, x_{j+1},\ldots, x_{n+1}).$$

Then set $M_{k} = P_{1}\cdot P_{2} \cdots P_{k}$.  Note that $\det
M_{k} = \pm 1$.  We have
$$(d_{1}(k), \ldots d_{n+1}(k)) = (1, \alpha_{1}, \ldots, \alpha_{n})M_{k}.$$
Set $M_{k} = (C_{1}(k),\ldots,C_{n+1}(k))$, where each $C_{m}(k)$ is a column
vector of the matrix.  Then, if $a_{k}=l$,
$$C_{m}(k) = C_{m+1}(k-1)$$
for $m\leq n$ and
$$C_{n+1}(k) = C_{1}(k-1) - C_{2}(k-1) -\ldots - C_{n}(k) - l
C_{n+1}(k-1).$$
If $a_{k}=(ij)$, then, for $1 \leq m \leq j+1$,
$$C_{m-1}(k) = C_{m}(k-1),$$
$$C_{j+1}(k) = C_{1}(k-1) - C_{2}(k-1) -\ldots - C_{i+1}(k),$$
and for $j+1 \leq m \leq n+1,$
$$C_{m}(k) = C_{m}(k-1).$$

Each $C_{k}(m)$ can be viewed as an element of the integer lattice
$Z^{n+1}$.  Then we have a method for producing elements of the
integer lattice that approach the hyperplane
$$x_{0} + \alpha_{1} x_{1} + \ldots + \alpha_{n}x_{n} =0.$$

It is still unknown how to determine when an n-triangle sequence will
uniquely determine an n-tuple
 $(\alpha_{1}, \ldots, \alpha_{n})\in\bigtriangleup$.  If we have
 uniqueness, we strongly suspect that

 $$\alpha_{j} = \lim_{k\rightarrow \infty}
 (-1)^{j}\frac{M_{k}(j1)}{M_{k}(11)},$$
 where $M_{k}(ij)$ denotes the determinant of the $n\times  n$ minor
 of $M_{k}$ obtained by deleting the ith row and jth column.   The moral, but incorrect argument, is
 the following.  First, since $\det M_{k}=\pm 1$, its
 column vectors are linearly independent.  But also, the column
 vectors are approaching the hyperplane
  whose normal vector is $(1, \alpha_{1}, \ldots, \alpha_{n})$.  Then
  via standard arguments, the wedge product $C_{2}(k)\wedge
  \ldots \wedge C_{n+1}(k)$  corresponds under duality to a vector
  perpendicular to $C_{2}(k),
  \ldots, C_{n+1}(k)$ and by normalizing, will
   approach the vector $(1, \alpha_{1}, \ldots, \alpha_{n})$

  With reasonable conditions about uniqueness, we should have
  \begin{conjecture}
Let $0 \leq  \alpha_{n} \leq \ldots  \leq  \alpha_{1} < 1$ be
an n-tuple  of numbers whose triangle
sequence is $(k,k,k,\ldots)$.  Then $ \alpha_{j} = \alpha_{1}^{j}$ and
$\alpha_{1}$
is a root of the algebraic equation
$$x^{n+1} + k x^{n} + x^{n-1} + \ldots  + x -1 = 0.$$
Further if $\alpha$ is the real root of this equation that is between
zero and one, then
$(\alpha, \alpha^{2}, \ldots, \alpha^{n})$ has purely periodic simplex
 sequence $(k,k,k,
\ldots)$.
\end{conjecture}
A similar result holds if the triangle sequence is purely periodic
of period length one of the form $(ij, ij, ij, \ldots)$.

We should also have
 \begin{conjecture}
 Let $(\alpha_{1}, \ldots, \alpha_{n})$ be an n-tuple real  numbers in
 $\bigtriangleup$ whose triangle sequence is eventually periodic.
 Then each $\alpha_{j}$  is algebraic of  degree at
 most n.  Finally, as a vector space over ${\bf Q}$, the dimension of
 ${\bf Q}[\alpha_{1}, \ldots, \alpha_{n}]$ is at most n.
 \end{conjecture}

Finally a comment about notation.  In the abstract it is claimed that
that we will express each $n$-tuple will be associated to a sequence
of nonnegative integers but in this section we look at sequences not
just of nonnegative integers but also of terms of the form $(ij)$ with
$ 1 \leq i \leq n-2$ and $i < j \leq n$.  But there are only a finite
number ( $n(n-2) + \frac{(n-2)(n-1)}{2}$) of these extra symbols.
We could, if desired, order these symbols by
nonnegative numbers $0,1,\ldots, n(n-2) + \frac{(n-2)(n-1)}{2}$ and
then shift the original nonnegative integers by this amount.  This
will force the sequence to be one of nonnegative integers, but the
notation is clearly worse than the one chosen.


Are monochromatic Pythagorean triples unavoidable under morphic colorings ?

Abstract: A Pythagorean triple is a triple of positive integers a, b, c $\in$ N${}^{+}$ satisfying a${}^2$ + b${}^2$ = c${}^2$. Is it true that, for any finite coloring of N${}^{+}$ , at least one Pythagorean triple must be monochromatic? In other words, is the Dio-phantine equation X${}^2$+ Y${}^2$ = Z${}^2$ regular? This problem, recently solved for 2-colorings by massive SAT computations [Heule et al., 2016], remains widely open for k-colorings with k $\ge$ 3. In this paper, we introduce morphic colorings of N + , which are special colorings in finite groups with partly multiplicative properties. We show that, for many morphic colorings in 2 and 3 colors, monochromatic Pythagorean triples are unavoidable in rather small integer intervals.

\section{Introduction}

A triple $(a,b,c)$ of positive integers is a \emph{Pythagorean triple} if it satisfies $a^2+b^2=c^2$, as $(3,4,5)$ for instance. Is it true that, for any finite coloring of the set of positive integers, monochromatic Pythagorean triples are unavoidable?  While this typical Ramsey-type question has been open for decades \cite{EG:81}, there is no consensual conjecture as to whether the answer should be positive or not \cite{G:08}. Yet in the simplest case of two colors, the problem has just been solved in the affirmative with the support of massive SAT computations, as follows \cite{HKM:15}.

\begin{theorem}\label{heule} For any $2$-coloring of the integer interval $I=[1,7825]$, there is a monochromatic Pythagorean triple in $I$. Moreover, $7825$ is minimal with respect to this property.
\end{theorem}

Prior to this achievement, J. Cooper and R. Overstreet had obtained, already with SAT computations, an exotic $2$-coloring of the integer interval $[1,7664]$ avoiding monochromatic Pythagorean triples~\cite{CO:15}. See also~\cite{CFHW:14} for a related earlier work. The general problem remains widely open for $k$-colorings with $k \ge 3$. For background on Ramsey theory, see \cite{GRS:90}.

In this paper, we tackle the problem by focusing on a restricted class of  colorings that we call \textit{morphic}\footnote{We thank the anonymous referee for suggesting this term.}\textit{colorings}, which are partly multiplicative maps in some group and depend on the choice of a few prime numbers. For all the morphic colorings in $2$ and $3$ colors considered here, monochromatic Pythagorean triples turn out to be unavoidable, as expected in the case of $2$ colors of course, but much sooner so than the general threshold of $7825$ in Theorem~\ref{heule}.

The present results lead us to conjecture that the answer to the question in the title is, in fact, positive.

\section{Notation and background}

We shall denote by $\mathbb N$ the set of nonnegative integers, by $\mathbb N_+ = \{n \in \mathbb N \mid n \ge 1\}$ the subset of positive integers, and by $\mathbb P=\{2, 3, 5, 7, 11, 13, \dots \}$ the subset of prime numbers. Given positive integers $a \le b$, we shall denote the integer interval they bound by
$$
[a,b] \ = \ \{c \in \mathbb N \mid a \le c \le b\}.
$$

\begin{definition}
A \emph{Pythagorean triple} is a triple $(a,b,c)$ of positive integers satisfying $a^2+b^2=c^2$.  Such a triple is said to be \emph{primitive} if it satisfies $\gcd(a,b,c)=1$.
\end{definition}

Obviously, since the equation $X^2+Y^2=Z^2$ is homogeneous, every Pythagorean triple is a scalar multiple of a primitive one.

The parametrization of primitive Pythagorean triples is well known. Indeed, \textit{every} primitive Pythagorean triple is of the form
$$
(m^2-n^2,2mn,m^2+n^2),
$$
where $m,n$ are coprime positive integers such that $m - n$ is positive and odd.

Following Rado \cite{Rad:33}, a Diophantine equation $f(X_1,\dots,X_n) = 0$ is said to be \textit{partition-regular}, or \textit{regular} for short, if for every finite coloring of $\mathbb N_+$, there is a monochromatic solution $(x_1,\dots,x_n) \in \mathbb N_+^n$ to it. More specifically, for given $k \in \mathbb N_+$, the equation is said to be \textit{$k$-regular} if, for every $k$-coloring of $\mathbb N_+$, there is a monochromatic solution to it. Note that regularity is equivalent to $k$-regularity for all $k \in \mathbb N_+$, and that $k$-regular implies $(k-1)$-regular if $k \ge 2$.

With this terminology, the question under study here is to determine whether the Diophantine equation $X^2+Y^2-Z^2=0$ is regular or not. And, if not, to determine the largest $k \ge 2$ for which this equation is $k$-regular. This problem is open since several decades. The only positive result about it so far is Theorem~\ref{heule}, which states that this equation is $2$-regular. It has been achieved by massive computations with a SAT solver in 35000 hours and validated in 16000 more hours with a 200TB certificate in the DRAT format \cite{HKM:15}.

The interest of our present approach with morphic colorings is three-fold. First, it allows us to test some $3$-colorings. Second, for all the $2$-colorings considered here, monochromatic Pythagorean triples turn out to be unavoidable much sooner, and at a much lower computational cost, than in Theorem~\ref{heule}. And third, as in Tao's recent solution of the Erd\H{o}s discrepancy conjecture~\cite{Tao:16}, partially multiplicative functions, like our morphic colorings, seem to be a good testbed for the problem under study.\footnote{Thanks are due to the anonymous referee for this observation.}

\section{Standard and partial morphisms }
\label{sect3}

In this paper, we introduce colorings of $\mathbb N_+$ by a finite additive group $G$ and satisfying special algebraic properties. Below, we shall mainly focus on the groups $\mathbb Z/2\mathbb Z$ and $\mathbb Z/3\mathbb Z$.

To start with, we consider monoid morphisms in the usual sense, i.e. maps $f \colon \mathbb N_+ \to G$ satisfying
$$
f(xy) = f(x)+f(y)
$$
for all $x,y \in \mathbb N_+$. Note that such a morphism is \textit{completely and freely determined by its values $\{f(p)\}_{p \in \mathbb P}$ on the prime numbers}.

\smallskip

These morphisms $f$ are particularly interesting in the present context, since if a primitive Pythagorean triple $(a,b,c)$ fails to be monochromatic under $f$, then the same holds for all its scalar multiples $(ad,bd,cd)$ with $d \in \mathbb N_+$. Indeed, if $f(x)\not=f(y)$, then $f(xd) \not= f(yd)$ for all $d \ge 1$. This follows from the property $f(zd) = f(z)+f(d)$ for all $z \in \mathbb N_+$ and the fact that the values lie in a group.

\smallskip

We shall prove in a subsequent section that, for any morphism $f \colon \mathbb N_+ \to G$ where  $G$ is either $\mathbb Z/2\mathbb Z$ or $\mathbb Z/3\mathbb Z$, monochromatic primitive Pythagorean triples are unavoidable. Of course, for $G=\mathbb Z/2\mathbb Z$, that result follows from Theorem~\ref{heule}. However, its computer-aided proof is computationally much lighter; moreover, the unavoidability threshold turns out to be $533$ only in that case, as compared to $7825$ in the general case.

These positive results lead us to somewhat relax the constraints of morphisms if we seek to observe new phenomena, if any. Yet some structure on the considered colorings is needed, so as to have a more manageable function space size. This prompts us to consider maps $f \colon \mathbb N_+ \to G$ satisfying weaker conditions than morphisms, and which we now define.

\medskip

First, for any positive integer $n$, we denote by supp($n$) the set of prime factors of $n$. For instance, supp$(60)=\{2,3,5\}$.

\begin{definition} Let $(G,+)$ be an abelian group. Let $\mathbb P_{0} \subseteq \mathbb P$ be a given subset of the prime numbers. We say that a map
$$
f \colon \mathbb N_+ \to G
$$
is a \emph{$\mathbb P_0$-partial morphism}, or a \emph{$\mathbb P_0$-morphism} for short,  if the following properties hold. For any $n \in \mathbb N_+$, let $n_0 \in \mathbb N_+$ be the largest factor of $n$ such that supp$(n_0) \subseteq \mathbb P_{0}$ and let $n_1=n/n_0$, so that $n=n_0n_1$. Then
\begin{itemize}
\item $f(n) = f(n_0) + f(n_1)$;
\item $f(n_1)=f(a)+f(b)$ for any coprime integers $a,b$ satisfying $n_1=a b$.
\end{itemize}
\end{definition}
An equivalent way of expressing this notion is as follows. For any $n \in \mathbb N_+$, consider its unique prime factorization
$$
n = \prod_{p \in \mathbb P} p^{\nu_p(n)}
$$
where $\nu_p(n) \in \mathbb N$ for all $p$. Then, the map $f \colon \mathbb N_+ \to G$ is a $\mathbb P_0$-morphism if for all $n \in \mathbb N_+$, we have
$$
f(n) = f\big(\prod_{p \in \mathbb P_0} p^{\nu_p(n)}\big) + \sum_{p \notin \mathbb P_0} f\big(p^{\nu_p(n)}\big).
$$
Thus, a $\mathbb P_0$-morphism is entirely and freely determined by its values on the set of positive integers
$$
S(\mathbb P_0) = \big\{n_0 \in \mathbb N_+ \mid \textrm{supp}(n_0) \subseteq \mathbb P_0\big\} \, \bigsqcup \, \big\{p^\nu \mid p \in \mathbb P \setminus \mathbb P_0, \nu \in \mathbb N_+\big\}.
$$
For instance, any $\{2,3\}$-morphism is freely  determined by its values on the integers of the form $2^a3^b$ and $p^c$ with $p \in \mathbb P$, $p \ge 5$, where $a,b,c\in \mathbb N$ and $a+b \ge 1$, $c \ge 1$.

\begin{remark} Here are a few easy observations about $\mathbb P_0$-morphisms $f \colon \mathbb N_+ \to G$.
\begin{itemize}
\item If $\mathbb P_0 = \emptyset$, then $f$ is characterized by the property $f(xy)=f(x)+f(y)$ for all coprime positive integers $x,y$. In particular, classical monoid morphisms are $\emptyset$-morphisms in the present sense.
\item On the other end of the spectrum, if $\mathbb P_0=\mathbb P$, then $f$ is just a set-theoretical map without any special property or structure.
\item More generally, if $\mathbb P_0 \subseteq \mathbb P_1 \subseteq \mathbb P$, then any $\mathbb P_0$-morphism is also a $\mathbb P_1$-morphism.
\end{itemize}
\end{remark}

\section{Colorings by standard morphisms}

The interest of using morphisms $f \colon \mathbb N_+ \to G$ as coloring functions is that such a coloring admits a monochromatic Pythagorean triple if and only if it admits a monochromatic \emph{primitive} Pythagorean triple. This is why we only need consider primitive Pythagorean triples in this section.

\begin{proposition}\label{morphism m=2} For any morphism $f \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$, monochromatic primitive Pythagorean triples are unavoidable. More precisely, such monochromatic triples are already unavoidable in the integer interval $[1,533]$. And finally, 533 is minimal with respect to this property.
\end{proposition}
The proof below relies on some computer assistance but, with patience, everything can be checked by hand.
\begin{proof} Let $f \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$ be any morphism. Then $f$ is determined by its values on the prime numbers via the formula
$$
f(n)=f\big(\prod_{p \in \mathbb P} p^{\nu_p(n)}\big) = \sum_{p \in \mathbb P} \nu_p(n) f(p)
$$
for any $n \in \mathbb N_+$. Plainly, the only primes $p$ which actually contribute to the value of $f(n)$ are those for which $\nu_p(n)$ is odd. For example, we have $f(12)=f(3)$.

For $n \in \mathbb N_+$, let us denote by oddsupp($n$) the \textit{odd support} of $n$, i.e. the set of primes $p$ for which $\nu_p(n)$ is odd. Thus, the above formula for $f(n)$ reduces to
$$
f(n)= \sum_{p} f(p),
$$
where $p$ runs through oddsupp$(n)$ only.

\smallskip

We shall restrict our attention to the 13 first primes, denoted $p_1,\dots,p_{13}$ in increasing order, and shall denote their set by $\mathbb P_{13}$. Thus $\mathbb P_{13}=\{2,3, \dots, 37,41\}$. Further, let us set
$$
\mathbb N_{|\mathbb P_{13}} = \{n \in \mathbb N_+ \mid \textrm{oddsupp}(n) \subseteq \mathbb P_{13} \}.
$$
For instance, the first few positive integers \textit{not} in $\mathbb N_{|\mathbb P_{13}}$, besides the primes $p \ge 43$, are 86, 94, 106, 118, 122, etc.

\medskip

By the above formula, the value of $f(n)$ for any $n \in \mathbb N_{|\mathbb P_{13}}$ is entirely determined by the length 13 binary vector
$$
v(f)=\big(f(p_1),\dots,f(p_{13})\big) \in (\mathbb Z/2\mathbb Z)^{13}.
$$
Consider now the set $\mathcal{T}$ of all primitive Pythagorean triples in the integer interval $[1,532]$. There are 84 of them, the lexicographically last one being $\{279, 440, 521\}$. Among them, we shall distinguish the subset $\mathcal{T}_{13}$ defined as
$$
\mathcal{T}_{13} = \big\{(a,b,c) \in \mathcal{T} \mid a,b,c \in \mathbb N_{|\mathbb P_{13}} \big\},
$$
i.e. those triples in $\mathcal{T}$ whose three elements have odd support in $\mathbb P_{13}$.
One finds that $|\mathcal{T}_{13}|=32$. For definiteness, here is this set:

\bigskip
\noindent
{\small
$\mathcal{T}_{13}=\big\{\{3,4,5\}$, $\{5,12,13\}$, $\{8,15,17\}$, $\{7,24,25\}$, $\{20,21,29\}$, $\{12,35,37\}$, $\{9,40,41\}$, $\{33,56,65\}$, $\{16,63,65\}$, $\{13,84,85\}$, $\{36,77,85\}$, $\{44,117,125\}$, $\{17,144,145\}$, $\{24,143,145\}$, $\{119,120,169\}$, $\{57,176,185\}$, $\{104,153,185\}$, $\{133,156,205\}$, $\{84,187,205\}$, $\{21,220,221\}$, $\{140,171,221\}$, $\{161,240,289\}$, $\{204,253,325\}$, $\{36,323,325\}$, $\{135,352,377\}$, $\{152,345,377\}$, $\{87,416,425\}$, $\{297,304,425\}$, $\{31,480,481\}$, $\{319,360,481\}$, $\{155,468,493\}$, $\{132,475,493\}\big\}$.
}

Perhaps surprisingly, it turns out that there are exactly two \textit{avoiding morphisms}
$$
f_1,f_2 \colon \mathbb N_{|\mathbb P_{13}} \to \mathbb Z/2\mathbb Z
$$
for which no $(a,b,c) \in \mathcal{T}_{13}$ is monochromatic. They are determined by the length 13 binary vectors $v(f_1)=w_1$, $v(f_2)=w_2$, where
\begin{eqnarray*}
w_1 & = & 0101111101001,\\
w_2 & = & 0101111111001.
\end{eqnarray*}
Note that $w_1,w_2$ only differ at the 9th digit.

Now, the 85th primitive Pythagorean triple is $(308, 435, 533)$. As it happens, that triple is mapped to $(0,0,0)$ by both $f_1$ and $f_2$. Indeed, the prime factorizations of 308, 435 and 533 only involve the primes
$$
\begin{matrix}
p_{1}=2, & p_{2}=3, & p_{3}=5, & p_{4}=7,\\
p_{5}=11,& p_{6}=13, & p_{10}=29, & p_{13}=41,
\end{matrix}
$$
and are the following: $308=p_1^2p_4p_5$, $435=p_2p_3p_{10}$, $533=p_6p_{13}$. Hence, for $f = f_1$ or $f_2$, we have
$$
\begin{array}{lllllll}
f(308) & =  & f(p_{4})+f(p_{5}) & = & 1 + 1 & = & 0, \\
f(435) & =  & f(p_{2})+ f(p_{3})+f(p_{10})   & =  & 1 + 0 + 1 & =  & 0, \\
f(533) & =  & f(p_{6})+f(p_{13})  & =  & 1 + 1 & =  & 0.
\end{array}
$$
We conclude, as claimed, that for every morphism $g \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$, there must be a primitive Pythagorean triple in $[1,533]$ which is monochromatic under $g$.

The fact that 533 is minimal with respect to this property is witnessed by the existence of many morphisms $f$ under which none of the 84 primitive Pythagorean triples in $[1,532]$ is monochromatic. The values on $p_1,\dots,p_{13}$ of these avoiding morphisms $f$ must of course be specified by either $w_1$ or $w_2$, but there are further restrictions. Indeed, their values on all primes turn out to be constrained as follows: either
$$
f(p_i) = \left\{
\begin{array}{ll}
0 & \textrm{for } i = 1,3,9,11,12,18,21,30,57,74,80,89, \\
1 & \textrm{for } i = 2,4,5,6,7,8,10,13,16,24,26,55,65,
\end{array}
\right.
$$
or
$$
f(p_i) = \left\{
\begin{array}{ll}
0 & \textrm{for } i = 1,3,11,12,18,21,25,30,59,74,89, \\
1 & \textrm{for } i = 2,4,5,6,7,8,9,24,26,55,65,70,
\end{array}
\right.
$$
with complete freedom on all other primes. Note that the 13 first bits of the first and of the second type, i.e. the $f(p_i)$'s for $i \le 13$, make up $w_1$ and $w_2$, respectively.
\end{proof}

\smallskip

An analogous result holds for morphic 3-colorings, established by an exhaustive computer search.

\begin{proposition}\label{morphism m=3} For any morphism $f \colon \mathbb N_+ \to \mathbb Z/3\mathbb Z$, monochromatic primitive Pythagorean triples are unavoidable. More precisely, at least one such triple in the integer interval $[1,4633]$ is monochromatic under $f$. And $4633$ is minimal with respect to that property.
\end{proposition}

Here is one particular morphism $f \colon \mathbb N_+ \to \mathbb Z/3\mathbb Z$ for which no Pythagorean triple in the interval $[1,4632]$ is monochromatic; it suffices to specify which primes in that interval are colored 1 or 2, the rest being colored 0. Denoting by $p_i$ the $i$th prime for $i \ge 1$, so that $p_1=2$, $p_2=3$, $p_3=5$ and so on, we set:
$$
f(p_i) \ = \
\left\{
\begin{array}{rl}
1 & \textrm{ if } i \in A, \\
2 & \textrm{ if } \ i \in \{6,7,23,24,29,30,33,74\}, \\
0 & \textrm{ otherwise, }
\end{array}
\right.
$$
where $A \ = \{1,2,5,11,12,13,16,17,19,20,21,25,37,45,55,65,68,70,71,82,84,
\newline 89,98,112,123,130,135,
151,189,198,203,220,245,267,345,355,359,381,401,
\newline 443,464,514,561,583,610,612,624\}.$ As said above, under this particular morphism, no Pythagorean triple in the interval $[1,4632]$ is monochromatic. For the record, there are 735 primitive Pythagorean triples in that interval.

\bigskip
Propositions~\ref{morphism m=2} and~~\ref{morphism m=3} give rise to an interesting problem which might be more manageable than the general regularity problem of the Pythagoras equation.
\begin{problem} Is it true that, for any $m \ge 4$ and any standard morphism $f \colon \mathbb N_+ \to \mathbb Z/m\mathbb Z$, monochromatic Pythagorean triples are unavoidable? And if yes, how does the unavoidability threshold behave as a function of $m$?
\end{problem}
Recall that for $m=2$ and $3$, the corresponding unavoidability threshold turns out to be $533$ and $4633$, respectively.

\section{Morphic colorings}
We now turn to $\mathbb P_0$-partial morphisms in the sense of Section~\ref{sect3}.
\begin{definition} A \emph{morphic coloring} of $\mathbb N_+$ is a $\mathbb P_0$-morphism where $\mathbb P_0$ is a finite subset of $\mathbb P$.
\end{definition}
In the sequel, we shall mostly consider morphic colorings of $\mathbb N_+$ in this sense.
Let us start first with an easy remark concerning primitive Pythagorean triples.

\begin{remark} There exist partial morphisms $f \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$ under which no \emph{primitive} Pythagorean triple is monochromatic.
\end{remark}
One obvious example is the 2-coloring given by $f(n)= 1$ if $n$ is even and 0 otherwise. Since any primitive Pythagorean triple $(a,b,c)$ contains exactly one even number, it is not monochromatic under $f$.

Two similar examples arise by mapping multiples of 3 to color 1, or else multiples of 5 to color 1, and the rest to color 0, respectively. Indeed, any primitive Pythagorean triple $(a,b,c)$ contains at least one multiple of 3, and one multiple of 5 as well; this easily follows from the fact that the only nonzero square mod 3 is 1, and the only nonzero squares mod 5 are $\pm 1$. But since $a,b,c$ are assumed to be coprime, and since $a^2+b^2=c^2$, they cannot be \textit{all three} mapped to 1, or to 0, by these two 2-colorings.

These three 2-colorings are $\emptyset$-morphisms, as they satisfy $f(xy)=f(x)+f(y)$ for all coprime positive integers $x,y$. More precisely, they are characterized by the values
$$
f(p_0^\nu)= 1, \ f(p^\nu)=0
$$
for all $\nu \ge 1$ and all primes $p \not = p_0$, where $p_0 = 2$, 3 or 5, respectively.

\medskip

Perhaps surprisingly, for any $\emptyset$-morphism $f \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$, it turns out again that monochromatic Pythagorean triples are unavoidable. Here are even stronger results, obtained by exhaustive computer search with an algorithm briefly described below.

\begin{proposition} For any $\mathbb P_0$-morphism $f \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$, where $\mathbb P_0$ is one of the sets $\{2,3,5\}$, $\{2,3,5,7\}$ and $\{2,3,5,7,11\}$, monochromatic Pythagorean triples are unavoidable. More precisely, they are unavoidable in the integer interval $[1,N]$, where
$$
N \ = \
\left\{
\begin{array}{rcl}
533 & \textrm{if} & \mathbb P_0=\{2,3,5\}, \\
565 & \textrm{if} & \mathbb P_0=\{2,3,5,7\}, \\
696 & \textrm{if} & \mathbb P_0=\{2,3,5,7,11\}.
\end{array}
\right.
$$
Moreover, in each case, the given $N$ is minimal with respect to that property.
\end{proposition}

\subsection{The algorithm}

Here is a brief description of the algorithm used. It consists of a recursive, backtracking
search, that tries to color all elements in Pythagorean triples within a given integer interval $[1,M]$ without creating monochromatic such triples.

Let us consider a fixed subset $\mathbb P_0 \subset \mathbb P$. The set of variables is then the set $S(\mathbb P_0)$ of positive integers defined in Section~\ref{sect3}, namely
$$
S(\mathbb P_0) = \big\{n_0 \in \mathbb N_+ \mid \textrm{supp}(n_0) \subseteq \mathbb P_0\big\} \, \bigsqcup \, \big\{p^\nu \mid p \in \mathbb P \setminus \mathbb P_0, \nu \in \mathbb N_+\big\}.
$$
For $n \in \mathbb N_+$, let us denote by
$\textit{fact}(n)=\{q_1, \ldots, q_k\}$ the unique subset of $S(\mathbb P_0)$ such that
$$n = \prod_{i=1}^{k} q_i$$
and where each $q_i \in S(\mathbb P_0)$ is \emph{maximal}, in the sense that no proper multiple of $q_i$ dividing $n$ belongs to $S(\mathbb P_0)$. Thus, for a given $\mathbb P_0$-morphism $f \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$, and for $n \in \mathbb N_+$, we have
$$
f(n) = \sum_{q \in \textit{fact}(n)} f(q).
$$
For instance, if $\mathbb P_0=\{2,3,5\}$ and $n=64680=2^3\cdot 3\cdot 5 \cdot 7^2 \cdot 11$, the maximal $S(\mathbb P_0)$-factors of $n$ are $120=2^3\cdot 3\cdot 5$, $49=7^2$ and $11$. Thus $\textit{fact}(n)=\{120,49,11\}$, and $f(n)=f(120)+f(49)+f(11)$ for any $\mathbb P_0$-morphism $f$ as above.

\medskip

The algorithm will try to assign a suitable color in $\mathbb Z/2\mathbb Z$ to each variable, but the order in which this is done is important and may strongly affect the running time. To define a proper assignment order, we introduce the following notation. Given a positive integer $M$, let $\mathbb T_M$ denote the set of all Pythagorean triples contained in the integer interval $[1,M]$. Then, for $q \in S(\mathbb P_0)$ and ${\{a,b,c\} \in \mathbb T_M}$, we define
$$
\delta_{q}^{\{a,b,c\}} \ = \
\left\{
\begin{array}{rl}
  1 & \textrm{ if } q \in \textit{fact}(a) \cup \textit{fact}(b) \cup \textit{fact}(c), \\
  0 & \textrm{ otherwise. }
\end{array}
\right.
$$
The \emph{weight} of the variable $q$ is now defined as
$$w(q) = \sum_{t \in \mathbb T_M}\delta_{q}^{t},$$
i.e. the number of Pythagorean triples in $[1,M]$ where $q$ appears in the
decomposition $\textit{fact}(n)$ of one of the triple elements $n$. The variables are then ordered by decreasing weight, and the algorithm assigns a value in
$\mathbb Z/2\mathbb Z$ to the variables in that order. Thus, variables constrained by the greatest number of triples in which they are involved as a maximal $S(\mathbb P_0)$-factor are tested first.

Once a variable is assigned, the algorithm performs forward arc
checking~\cite{bessiere2006constraint}; that is, it computes, if possible, the color of all
triple elements following the current
partial morphism. This color computation of an element $m$ is possible
if all variables in $\textit{fact}(m)$ are already colored as explained in
Section~\ref{sect3}.  If the coloration of any member creates a
monochromatic triple, then the algorithm tries the other color for the
variable if any left, or backtracks.

\subsection{The function $N(\mathbb P_0)$}

The above results prompt us to introduce the following function.

\begin{definition} For any subset $\mathbb P_0 \subseteq \mathbb P$, we denote by $N(\mathbb P_0)$ the largest integer $N$ if any, or $\infty$ otherwise, such that there exists a 2-coloring of the integer interval $[1,N]$ by a $\mathbb P_0$-morphism which avoids monochromatic Pythagorean triples in that interval.
\end{definition}

The above results may thus be expressed as follows:
\begin{eqnarray*}
N(\{2,3,5\}) & = &  532, \\
N(\{2,3,5,7\}) & = &  564, \\
N(\{2,3,5,7,11\}) & = &  695.
\end{eqnarray*}

\smallskip

Moreover, whether the equation $X^2+Y^2=Z^2$ is 2-regular or not is equivalent to whether $N(\mathbb P)$ is finite or infinite, respectively. This follows from a standard compactness argument.

\subsection{On small sets of primes up to 100}\label{up to 100}
Finally, we consider $\mathbb P_0$-morphisms $f \colon \mathbb N_+ \to \mathbb Z/2\mathbb Z$ where $\mathbb P_0$ ranges through all sets of prime numbers in $[2,100]$ of cardinality 3, 4 and 5. Note that $[2,100]$ contains 25 prime numbers. Needless to say, a considerable amount of code optimization and computer time were needed in order to establish the findings below.

The interest of the results below is that the unavoidability thresholds of monochromatic Pythagorean triples remain much smaller than $7825$, the general threshold of Theorem~\ref{heule}, and also that their numerical behavior turn out to be quite subtle.

\subsubsection{The case $|\mathbb P_0|=3$}

There are $\displaystyle \binom{25}{3} = 2300$ sets of three distinct prime numbers smaller than 100.

\begin{proposition}\label{triples} Among the $2300$ subsets $\mathbb P_0 \subset \mathbb P \cap [2,100]$ of cardinality 3, one has $N(\mathbb P_0)=532$ for all but 29 of them. These 29 exceptions are as follows:
$$
N(\mathbb P_0) \ = \
\left\{
\begin{array}{rl}
544 & \textrm{ if } \ \mathbb P_0 \in \big\{\{2,3,13\},\{3,5,17\},\{5,13,41\}\big\}, \\
564 & \textrm{ if } \ \mathbb P_0 \in \big\{\{2,3,7\}\big\} \cup \{\{7,11,a\} \mid a \in \mathbb P \cap [2,100]\setminus \{7,11\}\big\}, \\
628 & \textrm{ if } \ \mathbb P_0 \in \big\{\{2,3,19\},\{3,13,19\}\big\}.
\end{array}
\right.
$$
\end{proposition}

\subsubsection{The case $|\mathbb P_0|=4$}
There are $\displaystyle \binom{25}{4} = 12650$ sets of four distinct prime numbers smaller than 100.
\begin{proposition} For all subsets $\mathbb P_0 \subset \mathbb P \cap [2,100]$ of cardinality 4, one has
$$
532 \ \le \ N(\mathbb P_0)  \ \le \ 784
$$
and, more precisely,
\begin{eqnarray*}
N(\mathbb P_0) & \in & \{532, 543, 544, 547, 564, 577, 594, 614, 624, 628, \\
& & 649, 656, 662, 666, 679, 688, 696, 739, 778, 784\}.
\end{eqnarray*}
\end{proposition}
\begin{remark} The value $784$ above is attained only once, by $\mathbb P_0=\{3,5,19,23\}$. The same holds for the next few largest values, including $778=N(\{3,13,19,23\})$ and $739=N(\{2,3,19,23\})$. All three cases involve the subset $\{3,19,23\}$. Compare with the most performant triples found in Proposition~\ref{triples}, namely $\{2,3,19\}$ and $\{3,13,19\}$, both containing $\{3,19\}$.
\end{remark}
\begin{remark}
The behavior of $N(\mathbb P_0)$ may be quite subtle. For instance, one has $
N(\mathbb P_0) = 564$ for all quadruples $\mathbb P_0$ in $\mathbb P \cap [2,100]$ containing the pair $\{7,11\}$, with one single exception given by $N(\{7,11,13,17\}) = 624$.
\end{remark}

\subsubsection{The case $|\mathbb P_0|=5$}
There are $\displaystyle \binom{25}{5} = 53130$ sets of five distinct prime numbers smaller than 100.

\begin{proposition} For every subset $\mathbb P_0 \subset \mathbb P \cap [2,100]$ of cardinality 5, we have
$$
532 \ \le \ N(\mathbb P_0)  \ \le \ 900.
$$
Moreover, the only such subsets $\mathbb P_0$ attaining the maximum $N(\mathbb P_0) = 900$ are
$$
\{2,3,7,19,23\}, \ \{2,3,17,19,23\}.
$$
\end{proposition}

\subsection{Summary}
The findings of section~\ref{up to 100} may be summarized as follows.
\begin{proposition} For every subset $\mathbb P_0 \subset \mathbb P \cap [2,100]$ of cardinality at most 5, and for every 2-coloring
$$
f \colon [1,901] \to \mathbb Z/2\mathbb Z
$$
by a $\mathbb P_0$-morphism, monochromatic Pythagorean triples are unavoidable.
\end{proposition}

\medskip

As for the $\displaystyle \binom{25}{6} = 177100$ subsets of cardinality 6 of $\mathbb P \cap [2,100]$, an exhaustive search cannot currently be completed in a reasonable amount of time. A first partial search has yielded 900 again as the highest value of $N(\mathbb P_0)$ found so far, achieved by the following subsets:
$$
\begin{array}{c}
\{2, 3, 5, 7, 19, 23\}, \,
\{2, 3, 5, 11, 19, 23\}, \,
\{2, 3, 5, 19, 23, 41\}, \, \\
\{2, 3, 5, 17, 19, 23\}, \,
\{2, 3, 5, 19, 23, 47\}, \,
\{2, 3, 5, 19, 23, 53\}.
\end{array}
$$
Interestingly, looking more closely at the results of section~\ref{up to 100}, one notes that the subsets $\mathbb P_0 \subset \mathbb P \cap [2,100]$ maximizing the function $N$ all contain $\{3,19\}$ if $|\mathbb P_0|=3$, or $\{3,19,23\}$ if $|\mathbb P_0|=4$, or $\{2,3,19,23\}$ if $|\mathbb P_0|=5$. While the case $|\mathbb P_0|=6$ is largely incomplete, an analogous statement might well hold.

\bigskip
\noindent

We thank the Editors of this journal and the anonymous referee for viewing favorably this paper in light of the general $2$-regularity result of \cite{HKM:15}, and the referee again for his/her highly valuable comments. We also thank Gyan Prakash for interesting information related to this work and for reference \cite{FH:14}.

Combinatorics (math.CO); Discrete Mathematics (cs.DM); Number Theory (math.NT)