The number of representations of by
squares, allowing zeros and distinguishing signs and order,
is denoted
.
The special case
corresponding to two squares is often denoted simply
(e.g., Hardy and Wright 1979, p. 241; Shanks
1993, p. 162).
For example, consider the number of ways of representing 5 as the sum of two squares:
(1)
| |||
(2)
| |||
(3)
| |||
(4)
| |||
(5)
| |||
(6)
| |||
(7)
| |||
(8)
|
so .
Similarly,
(9)
| |||
(10)
| |||
(11)
| |||
(12)
| |||
(13)
| |||
(14)
|
so .
The Wolfram Language function SquaresR[k,
n] gives .
In contrast, the function PowersRepresentations[n,
k, 2] gives a list of unordered unsigned representations of
as a list of
squares, e.g., giving the
as the only "unique" representation of 5.
The function
is intimately connected with the Leibniz series
and with Gauss's circle problem (Hilbert
and Cohn-Vossen 1999, pp. 27-39). It is also given by the inverse Möbius
transform of the sequence
and
(Sloane and Plouffe 1995, p. 22). The
average order of
is
,
but the normal order is 0 (Hardy 1999, p. 55).
Jacobi gave analytic expressions for for the cases
, 4, 6, and 8 (Jacobi 1829; Hardy and Wright 1979, p. 316;
Hardy 1999, p. 132). The cases
, 4, and 6 were found by equating coefficients
of the Jacobi theta functions
,
, and
. The solutions for
and 12 were found by Liouville (1864, 1866) and Eisenstein
(Hardy and Wright 1979, p. 316), and Glaisher (1907) gives a table of
for up to
. However, the formulas for
and
contained functions defined only as the coefficients of
modular functions, but not arithmetically (Hardy and Wright 1979, p. 316). Ramanujan
(2000) extended Glaisher's table up to
. Boulyguine (1915) found a general formula for
in which every function has an arithmetic definition
(Hardy and Wright 1979, p. 316; Dickson 2005, p. 317).
was found as a finite sum involving quadratic reciprocity symbols by Dirichlet.
and
were found by Eisenstein, Smith, and Minkowski. Mordell,
Hardy, and Ramanujan have developed a method applicable to representations by an
odd number of squares (Hardy 1920; Mordell 1920, 1923; Estermann 1937; Hardy 1999).
To find in how many ways a positive integer can be expressed as a sum of
squares ignoring order and signs, factor it as
(15)
|
where the s
are primes of the form
and the
s are primes of the form
. If
does not have such a representation with integer
because one or more of the powers of
is odd, then there are no representations. Otherwise, define
(16)
|
The number of representations of as the sum of two squares ignoring order and signs
is then given by
(17)
|
(Beiler 1966, pp. 140-142).
Similarly,
for
is given by
(18)
|
A positive integer can be represented as the sum of two squares iff each of its prime
factors of the form occurs as an even power, as first established by Euler
in 1738. In Lagrange's four-square theorem,
Lagrange proved that every positive integer can
be written as the sum of at most four squares,
although four may be reduced to three except for numbers of
the form
.
Diophantus first studied a problem equivalent to finding three squares whose sum is ,
and stated that for this problem,
must not be of the form
, which is however an insufficient condition (Dickson 2005,
p. 259). In 1621, Bachet subsequently excluded
and
. Finally, Fermat (ca. 1636) remarked that Bachet's condition
failed to exclude
, 149, etc., and gave the correct sufficient condition that
must not be of the form
, so
not of the form
, or equivalently
.
In 1636, Fermat stated that no integer of the form is the sum of three rational squares, and in 1638, Descartes
proved this for integer squares. In 1658, Fermat subsequently asserted (but did not
prove) that
,
where
is any prime of the form
(i.e., any prime of the form
) is the sum of three squares. In 1775, Lagrange made some
progress on Fermat's assertion, but could not completely prove it. In 1785, Legendre
remarked that Fermat's assertion is true for all odd numbers (not just primes), and
then gave an incomplete proof that either every number or its double is a sum of
three squares.
Beguelin (1774) had concluded that every integer congruent to 1, 2, 3, 5 or 6 (mod 8) is a sum of three squares, but without adequate proof (Dickson 2005, p. 15).
Then, in Legendre's 1798 Théorie des nombres, Legendre proved that
every positive integer not of the form or
is a sum of three squares having no common factor (Nagell
1951, p. 194; Wells 1986, pp. 48 and 56; Hardy 1999, p. 12; Savin
2000).
is 0 whenever
has a prime divisor of
the form
to an odd power; it doubles
upon reaching a new prime of
the form
.
The first few values are 1, 4, 4, 0, 4, 8, 0, 0, 4, 4, 8, 0, 0, 8, 0, 0, 4, 8, 4,
0, 8, 0, 0, 0, 0, 12, 8, 0, 0, ... (OEIS A004018).
A Lambert series was given by
(19)
|
(Hardy and Wright 1979, p. 258). The generating function for is given by
(20)
| |||
(21)
| |||
(22)
|
where
is a Jacobi elliptic function and
is a q-Pochhammer symbol.
It is given explicitly by
(23)
| |||
(24)
| |||
(25)
|
where
is the number of divisors of
of the form
(Hilbert and Cohn-Vossen 1999, pp. 37-38; Hardy 1999,
p. 12).
obeys the unexpected identities
(26)
|
for ,
(27)
|
and
(28)
|
(Hardy 1999, p. 82).
The first few values of the summatory function (e.g., Hardy and Wright 1979, p. 270) defined by
(29)
|
are 0, 4, 8, 8, 12, 20, 20, 20, 24, 28, 36, ... (OEIS A014198), where the modified function defined by Shanks (1993) is
(30)
| |||
(31)
|
Explicit values of for several powers of 10 are given in the following table
(Mitchell 1966; Shanks 1993, pp. 165 and 234).
0 | 5 |
1 | 37 |
2 | 317 |
3 | 3149 |
4 | 31417 |
5 | 314197 |
6 | 3141549 |
8 | 314159053 |
10 | 31415925457 |
12 | 3141592649625 |
14 | 31415926535058 |
Asymptotic results include
(32)
| |||
(33)
|
where
is a constant known as the Sierpiński constant.
The left plot above shows
(34)
|
with
illustrated by curved envelope, and the right plot shows
(35)
|
with the value of indicated as the solid horizontal line.
The number of solutions of
(36)
|
for a given
without restriction on the signs or relative sizes of
,
, and
is given by
. Gauss proved that if
is squarefree and
, then
(37)
|
(Arno 1992), where is the class number of
.
The generating function for is given by
(38)
| |||
(39)
|
and in general,
(40)
|
For ,
(41)
|
Identities for ,
and
are given by
(42)
| |||
(43)
|
where
and
(44)
|
(Jacobi 1829, §40-42; Smith 1965; Hardy and Wright 1979, p. 314).
For ,
(45)
|
where
(46)
| |||
(47)
| |||
(48)
|
This equation and that for were given by Liouville (1864, 1866).
(49)
| |||
(50)
| |||
(51)
|
where
(52)
| |||
(53)
|
is a so-called singular series, and
is the tau function.
Similar expressions exist for larger even , but they quickly become extremely complicated and can be
written simply only in terms of expansions of modular functions.