What is the solution of the equation $x^2+y^2+z^2+t^2=w^2$ in polynomials over C ("Pythagorean 5-tuples")?

There are simple formulas describing Pythagorean n-tuples for n=3,4,6:

  • n=3. The formula for solutions of $x^2+y^2=z^2$ [4]:




where p,q,d are arbitrary polynomials.

  • n=4. Similarly, all Pythagorean 4-tuples of polynomials are given by the identity [4, Theorem 2.2], [3, Theorem 7.1]:


  • n=6. The following identity produces Pythagorean 6-tuples [3, Theorem 7.2]:




where $m=(m_1,m_2,m_3,m_4)$, $n=(n_1,n_2,n_3,n_4)$, and $mn$ is the usual scalar product.

These identities are somehow related to sl(2,R), sl(2,C), sl(2,H), but the case n=5 is missing in this description [3, Theorems 7.1 and 7.2].

The above formuli describe also Pythagorean n-tuples of integers. There are another descriptions of those; see [2] and [5, Chapter 5] for n<10, [6] for n<15, [1, Theorem 1 in Chapter 3] for arbitrary n, and also the answers below.

There are reasons to believe that Pythagorean 5-tuples cannot be described by a single polynomial identity. Thus identities producing a "large" set of solutions are also of interest, like $(-p^2+q^2+r^2+s^2)^2+(2pq)^2+(2pr)^2+(2ps)^2=(p^2+q^2+r^2+s^2)^2$

This identity does not give all solutions because it produces only reducible polynomials y,z,t (once p,q,r,s are nonconstant). Examples of solutions which cannot be obtained by the approaches in the answers below are also interesting.

Given a solution (x,y,z,t,w), methods to construct a new solution (x',y',z',t',w') are also of interest. For instance,






[see the answer of Ken Fan below for generalizations to other n] or


where $q$ is arbitrary polynomial with quaternionic coefficients [see the answer of Geoff Robinson below].


[1] L.J. Mordell, Diophantine Equations, Academic Press, London, 1969

[2] D. Cass, P.J. Arpaia, MATRIX GENERATION OF PYTHAGOREAN n-TUPLES, Proc. AMS 109:1 (1990), 1-7

[3] J. Kocik, Clifford Algebras and Euclid’s Parametrization of Pythagorean Triples, Adv. Appl. Clifford Alg. 17:1 (2007), 71-93

[4] R. Dietz, J. Hoschek and B. Juttler, An algebraic approach to curves and surfaces on the sphere and on other quadrics, Computer Aided Geom. Design 10 (1993) 211-229

[5] V. Kac, Infinite-Dimensional Lie Algebras (3rd edn. ed.), CUP, 1990

[6] E. Vinberg, The groups of units of certain quadratic forms (Russian), Mat. Sbornik (N.S.) 87(129) (1972), 18–36

  • 7
    $\begingroup$ The general solution of this equation (for any number of squares) is given in Mordell's "Diophantine Equations", Thm 1 Chapter 3. $\endgroup$ Commented Apr 24, 2011 at 10:31
  • 1
    $\begingroup$ The question was initially posed for solutions both in polynomials and integers. Most of the answers below refer to solutions in integers. The accepted answer provides the largest available set of solutions in polynomials. $\endgroup$ Commented May 7, 2011 at 21:05
  • 2
    $\begingroup$ In 7, Theorem 1.2 one can find a parametrization of all Pythagorean 6-tuples of real polynomials in 2 variables having degree at most 2 in each variable. That is the simplest case not accessible by known methods. $\endgroup$ Commented Aug 16, 2016 at 16:56

6 Answers 6


One way to generate integer solutions is as follows: Let $ v = (p + qi + rj + sk)$, where $p,q,r,s$ are rational integers and $\{1,i,j,k\}$ is the usual $\mathbb{R}$-basis for the algebra of quaternions. Let $v^{\prime}= (p -qi -rj - sk)$ and $w = vv^{\prime} = (p^{2}+q^{2}+r^{2}+s^{2}).$ If we expand $v^{2}$ in the form $x + yi + zj +tk$ for integers $x,y,z,t$, then we do have $x^{2} + y^{2} + z^{2} + t^{2} = w^{2}$. This is somewhat analogous to generating the Pythagorean triple $(x^{2}-y^{2})^{2}$ + $(2xy)^{2}$ = $(x^{2}+y^{2})^{2}$ by taking $({\rm Re}(x+iy)^{2})^{2} + ({\rm Im}(x+iy)^{2})^{2} = (x^{2}+y^{2})^{2}$. It may be better to work with Hurwitz quaternions for this question.

Answer extended following the answer of Alex qubeat below, and slight rephrasing of the original question to place more emphasis on polynomials: At least in the context of polynomials in $\mathbb{R}[u]$ (it is easy to run out of letters in this game, so $u$ denotes an indeterminate here), more solutions may be manufactured using the fact that the solutions to $x(u)^{2} +y(u)^{2} + z(u)^{2} + t(u)^{2} = w(u)^{2}$ with $x(u),y(u),z(u),t(u),w(u) \in \mathbb{R}[u]$ have a semigroup structure. Alex's answer combines a fixed solution with an essentially ``constant" solution, to produce other solutions, but solutions can be combined in other ways. Let $\mathbb{H}$ denote the algebra of real quaternions. Then the map $N: \mathbb{H}[u] \to \mathbb{R}[u]$ with $N(x(u) +iy(u)+jz(u) + kt(u)) =x(u)^{2} +y(u)^{2} + z(u)^{2} +t(u)^{2}$ (for real polynomials $x(u),y(u),z(u),t(u))$ is multiplicative. The polynomials $p(u) \in \mathbb{H}[u]$ such that $N(p(u))$ is a non-zero square in $\mathbb{R}[u]$ are closed under multiplication.

As in the integral case, one way to ensure that $N(x(u) + iy(u) + jz(u) + kt(u))$ is a square is to take $x(u) + iy(u) +jz(u)+kt(u)$ to be of the form $(a(u)+ib(u)+jc(u)+kd(u))^{2}$ for real polynomials $a(u),b(u),c(u),d(u)$, but it is also clear from this discussion that $N(p_{1}(u)p_{2}(u) \ldots p_{n}(u))$ is a square in $\mathbb{R}[u]$ as long as any given $p_{i}(u)\in \mathbb{H}[u]$ occurs an even number of times in the (non-commuting) product. In fact, it is permissible to count the total number of occurences of $\mathbb{H}$-conjugates of any given $p_{i}(u)$, that is elements of the form $v^{-1}p_{i}(u)v$, where $v$ is a non-zero element of $\mathbb{H}$, since $N$ takes a constant value on the $\mathbb{H}^{\times}$-conjugacy class of $p_{i}(u)$.

Further remarks. May 6: The polynomial ring $\mathbb{H}[u]$ has a natural division ring of fractions, $\mathbb{H}(u)$, which is isomorphic to a certain ring of $2 \times 2$ matrices over $\mathbb{C}(u)$ (I can't get the latex right for matrices, but the ring should be clear- in particular, the determinants of elements in the ring are elements of $\mathbb{R}(u)$). There is a natural ring homomorphism $\sigma$ from $\mathbb{H}(u)$ to ${\rm SO}(3,\mathbb{R}(u))$, obtained by letting $\mathbb{H}(u) \backslash \{0\}$ act by conjugation of the $\mathbb{R}(u)$-span of $\{i,j,k\}.$

The question about polynomials amounts to determining $S\sigma$, where $S$ is the set of elements of $\mathbb{H}(u)$ whose determinants are squares in $\mathbb{R}(u)$. This is the same as $T\sigma$, where $T$ is the set of elements of determinant $1$, since the non-zero elements of $\mathbb{R}(u)$ acts trivially by conjugation on $\mathbb{H}(u)$. Now it is clear that $T\sigma$ is a normal subgroup of ${\rm SO}(3,\mathbb{R})$, and that the factor group is an elementary Abelian $2$-group (that is, an Abelian group of exponent $2$). I do not see at present how to calculate the size of this group, but record this line of thinking in case anyone else can exploit it further.

More remarks, May 13: I think that $\mathbb{H}(u)$ has an involutory automorphism $\sigma$ which fixes $\mathbb{R}(u)$ elementwise, and which has $i \sigma = -i$,$j\sigma = k$ and $k\sigma =j.$ Then $N(p(u)\sigma) = N(p(u))$ for all $p(u) \in \mathbb{H}(u)$. Hence, for any $p(u) \in \mathbb{H}(u)$, the element $q(u) = p(u).p(u)\sigma$ will have $N(q(u)) =w(u)^{2}$ for some $w(u) \in \mathbb{R}(u)$, so this will yield a new type of solution (at least in the context of this answer).

  • $\begingroup$ Thank you. Both your approach and the formula from Mordell's "Diophantine Equations" (chapter 3) describes the solutions obtained by "inverse stereographic projection" of the 3-space with the coordinates $p:q:r:s$ to the 3-sphere $x^2+y^2+z^2+t^2=w^2$: $(p^2-q^2-r^2-s^2)^2+(2pq)^2+(2pr)^2+(2ps)^2=(p^2+q^2+r^2+s^2)^2$. This provides a "large" set of Pythagorean 5-tuples of polynomials, if one takes arbitrary polynomials p,q,r,s. Not every Pythagorean 5-tuple of polynomials can be obtained in this way, thus other formulas are also of interest. $\endgroup$ Commented Apr 24, 2011 at 11:54
  • $\begingroup$ @mikhail What is a polynomial 5-tuple not obtained from this and what is the formula for polynomial solutions to $x^2+y^2=z^2$ that you have in mind? $\endgroup$ Commented Apr 24, 2011 at 19:17
  • $\begingroup$ @aaron The formula for polynomials solutions of $x^2+y^2=z^2$ is $x=d(p^2-q^2)$, $y=2dpq$, $z=d(p^2+q^2)$, where p,q,d are arbitrary polynomials. It is known that a similar formula for n=1 does not provide all 4-tuples [4, Theorem 2.2 and end of Section 3.2]. There are reasons to believe that there are also 5-tuples not obtained in this way but I cannot give an example immediately. $\endgroup$ Commented Apr 25, 2011 at 10:22
  • $\begingroup$ Extended answer is beautiful! It provides a large set S of solutions, and now we know that S is a sub-semigroup of the semigroup of all the solutions. Are there any ideas if 1) there are examples of Pythagorean 5-tuples not in S; 2) we need arbitrary n, or any element of S can be represented as, say, (x,y,z,t)=p1p2p2p1, w=|p1p2|^2, where p1,p2 belong to H[u]? $\endgroup$ Commented May 3, 2011 at 7:28
  • $\begingroup$ Answer of doetoe can be a candidate for a counter-example to 2). $\endgroup$ Commented May 7, 2011 at 13:35

In the early 90s, I took a class from Victor Kac and in it, he explained a very beautiful way of generating all the primitive solutions for the Pythagorean equation for a sum of $n-1$ perfect squares is equal to a perfect square where $n$ can be 3, 4, 5, ..., 10. Unfortunately, I do not know where in the literature this is described in detail. It might be in his Infinite Dimensional Lie Algebras book, but I don't know.

The idea is to realize the solutions as the isotropic roots for a certain root system.

Consider the lattice ${\Bbb Z}^n$ with bilinear form $-x_0y_0 + x_1y_1 + \cdots + x_{n-1}y_{n-1}$ and standard basis $v_0,\ v_1,\ v_2,\ \dots,\ v_{n-1}$.

Change basis to:

$\alpha_1 = v_1 - v_2$, $\alpha_2 = v_2 - v_3$, $\dots$, $\alpha_{n-2} = v_{n-2} - v_{n-1}$, and $\alpha_{n-1} = v_{n-1}$.

If $n \geq 4$, let $\alpha_n = -v_0 - v_1 - v_2 - v_3$.

If $n=3$, let $\alpha_n = -v_0 - v_1 - v_2$.

The corresponding Cartan matrix $a_{ij} = \frac{2(\alpha_i, \alpha_j)}{(\alpha_i, \alpha_i)}$ is represented by the diagram:

     alt text (source)

Then the set of primitive solutions to the equation $x_0^2 = x_1^2 + x_2^2 + \cdots + x_{n-1}^2$ is the orbit under the corresponding Coxeter group of $(1, 1, 0, \dots, 0)$ if $n < 10$. If $n=10$, then you have to add the orbit $(3, 1, 1, 1, \dots, 1)$ to get them all.

One doesn't need the theoretical machinery to prove the result. One can just construct the matrices and use a descent argument to show that it works.

For the Pythagorean triple case, for instance, you take the orbit of the vector $(1, 1, 0)$ under the action of the group generated by the matrices:

$$ \begin{pmatrix} 1 & 0 & 0 \\ 0 & 0 & 1\\ 0 & 1 & 0 \end{pmatrix}, $$

$$ \begin{pmatrix} \pm 1 & 0 & 0 \\ 0 & \pm 1 & 0 \\ 0 & 0 & \pm 1 \end{pmatrix}, $$ and

$$ \begin{pmatrix} 3 & 2 & 2 \\ 2 & 1 & 2 \\ 2 & 2 & 1 \end{pmatrix}. $$

For $n=4$, you can use the matrices that permute the appropriate variables, change the sign of any variable, and the following:

$$ \begin{pmatrix} 2 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \end{pmatrix}. $$

I'm sorry I cannot give a reference to the literature...I hope someone else is able to.

  • 6
    $\begingroup$ This is cool. :) $\endgroup$
    – B. Bischof
    Commented May 1, 2011 at 16:18
  • $\begingroup$ Very cool, indeed. $\endgroup$
    – Igor Rivin
    Commented May 6, 2011 at 14:41
  • 4
    $\begingroup$ Vinberg showed that O(n,1;Z) is generated by reflections up to finite index up to dimension 19. See: ams.org/mathscinet-getitem?mr=295193 ams.org/mathscinet-getitem?mr=476640 Vinberg gave an algorithm for finding reflection subgroups of arithmetic groups. Isotropic vectors of the quadratic form up to the action of O(n,1;Z) correspond to cusps of the hyperbolic orbifold. These in turn correspond to unimodular Euclidean lattices. Your answer is not really relevant to the question, unless you can discover the appropriate analogue of Vinberg's algorithm and lattices. $\endgroup$
    – Ian Agol
    Commented May 6, 2011 at 15:36
  • 1
    $\begingroup$ (see also Ch. 26 Conway Sloane) books.google.com/… $\endgroup$
    – Ian Agol
    Commented May 6, 2011 at 15:38
  • 1
    $\begingroup$ a reference: Daniel Cass and Pasquale J. Arpaia, "Matrix generation of Pythagorean n-tuples", Proc. Amer. Math. Soc. 109 no. 1 (1990) pp. 1-7 jstor.org/stable/2048355 $\endgroup$ Commented Feb 28, 2020 at 22:19

A parametrization of solutions is





$w=a^2+b^2+c^2+d^2\, .$

It is easy to see that this generates all rational solutions if $a, b, c, d$ are rational numbers, and (consequently) all integers solutions up to a similarity factor, if $a, b, c, d$ are integers.

[edit] for what it's worth, here's something more symmetric (with the same rmk as before)





$w=\phantom{-}2(a^2+b^2+c^2+d^2)\, .$

  • $\begingroup$ details: a first rational parametrization comes taking freely rational numbers $x, y, z, s$, taking $w=t+s$ in the equation and solving in $s$. Normalizing with $2s$ gives the general solution I wrote. $\endgroup$ Commented Apr 24, 2011 at 11:51

The construction below shows that such tuples really hardly could be written in unique way. Maybe some exclusion from general case is due to the Hurwitz theorem about sum of squares and noncommutativity of quaternions. This construction is modification of Pietro Majer and Geoff Robinson suggestions.

Let us consider quaternion $q = t + x i + y j + z k$ and a constant quaternion $c$. I am not sure after reading of the question, if norm should be a square of some integer or not. It may be Hurwitz quaternion and simple nontrivial example is $c=(1+i+j+k)/2$. Now let us consider product $s = q c q$ as polynomial of $t, x, y, z$.

We have $|s| = |c| |q|^2 = |c| (t^2+x^2+y^2+z^2)^2 $, but $|s|=s_0^2+s_1^2+s_2^2+s_3^2$ for $s = s_0 + s_1 i + s_2 j +s_3 k$, where $s_0, s_1, s_2, s_3$ by definition are second order polynomial of $t, x, y, z$.

So different $c$ produces different tuples and $c=1$ produces solution mentioned by Pietro Majer and Geoff Robinson and in Mordell book.

[edit] To produce more general solution for second order polynomials it is possible to use some modification. Let's consider three constant quaternions $a, b, c$ with modules are squares of some integers. It may be done using Kac's method or something else. Then new solution is $a q c q b$.

  • 2
    $\begingroup$ @Alex Thank you, this sounds really interesting! For c=1 and c=1+i+j+k your approach gives the 1st and the 2nd parametrizations by Pietro Majer, respectively. These solutions are distinct (x is a reducible polynomial in the 1st one and not necessarily in the 2nd one). Your approach can generalized as follows. Set $q=q_0+q_1i+q_2j+q_3k$ $c=c_0+c_1i+c_2j+c_3k$ where q0...q3, c0...c3 are arbitrary polynomials. Set $s=s_0+s_1i+s_2j+s_3k:=qccq$ Then the identity $s_0^2+s_1^2+s_2^2+s_3^2=((q_0^2+q_1^2+q_2^2+q_3^2)(c_0^2+c_1^2+c_2^2+c_3^2))^2$ produces Pythagorean 5-tuples. $\endgroup$ Commented May 2, 2011 at 12:50
  • 1
    $\begingroup$ I should note, the Kac's construction mentioned by Ken Fan may be found in “Infinite dimensional Lie algebras”, CUP 1990 (year is important, because it lacks in some earlier editions, e.g. Birkhauser 1983) in chapter 5 and produces all integer solutions as an orbit of single element. So it is enough to consider some polynomial solution and apply matrices mentioned by Kac. It may be useful computer algebra exercise to check idea, if all transformation mentioned in Kac's construction may be expressed as $a q c q a^{-1}$, there a is yet another quaternion constant. $\endgroup$ Commented May 3, 2011 at 19:42
  • $\begingroup$ Added your reference to the question $\endgroup$ Commented May 4, 2011 at 8:21
  • $\begingroup$ Applying the Kac matrix basically turns a solution (x,y,z,t,w) to the new solution $x'=w-y-z$, $y'=w-z-x$, $z'=w-x-y$, $t'=t$, $w'=2w-x-y-z$. The latter typically consists of polynomials of the same degree as the initial one, thus we do not get a large set of solutions in this way. On the other hand, q':=x'+iy'+jz'+kt' cannot be expressed through q:=x+iy+jz+kt in the form $q'=aqa^{-1}$ for a constant quaternion $a$ (because, say, x' depends on the variable w). Thus the Kac reproduction method is principally different from the one suggested by Alex 'qubeat' and Geoff Robinson. $\endgroup$ Commented May 7, 2011 at 11:46
  • $\begingroup$ To edited answer: just notice that we do not need to care about the norm of a,b,c because we are looking for solutions in polynomials over C. $\endgroup$ Commented May 7, 2011 at 11:50

Another way to generate parametrisations is to repeatedly apply a parametrisation of triples:

Say we start with $$(x(s), y(s)) = (\frac{2s}{s^2 + 1}, \frac{s^2 - 1}{s^2 + 1}),$$ satisfying $$x(s)^2 + y(s)^2 = 1.$$

To parametrise solutions to $x^2 + y^2 + z^2 = 1$, write $x^2 + y^2 = 1 - z^2$ which we set equal to $w^2$, so that a parametrised solution $(w(t), z(t))$ to $w^2 + z^2 = 1$ gives rise to a parametrised solution $$(w(t)x(s), w(t)y(s), z(t)) = (\frac{2t}{t^2 + 1}\cdot\frac{2s}{s^2 + 1}, \frac{2t}{t^2 + 1}\cdot\frac{s^2 - 1}{s^2 + 1}, \frac{t^2 - 1}{t^2 + 1})$$ to $x^2 + y^2 + z^2 = 1$.

Repeating this, we get your case:

$$(\frac{2u}{u^2 + 1}\cdot\frac{2t}{t^2 + 1}\cdot\frac{2s}{s^2 + 1}, \frac{2u}{u^2 + 1}\cdot\frac{2t}{t^2 + 1}\cdot\frac{s^2 - 1}{s^2 + 1}, \frac{2u}{u^2 + 1}\cdot\frac{t^2 - 1}{t^2 + 1}, \frac{u^2 - 1}{u^2 + 1})$$ parametrises $$x^2 + y^2 + z^2 + w^2 = 1$$ (to go to your original problem you can throw in another parameter to homogenise, clear denominators and multiply everything by another parameter).

If you apply the same to the parametrisation $(\cos(t), \sin(t))$ of the circle, you get a parametrisation of the 2-sphere by sperical coordinates.

  • $\begingroup$ Thank you for a nice parametrization. This fits well the approach of Geoff Robinson. If S=s+1+i(s-1), T=t+1+j(s-1), U=u+1+k(u-1) and STUUTS=v+ix+jy+kz then ( x,y,z,v,(s^2+1)(t^2+1)(u^2+1) ) coincides with your solution. $\endgroup$ Commented May 7, 2011 at 13:05

In fact, the equation:


Solutions look like this:






And the formula:






Where the numbers: $p,c,s,a,k,b$ integers and set us. Quite often, after a number of substitutions should be divided by the greatest common divisor.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.