In number theory, the sum of squares function is an arithmetic function that gives the number of representations for a given positive integer n as the sum of k squares, where representations that differ only in the order of the summands or in the signs of the numbers being squared are counted as different.
It is denoted by rk(n).
The function is defined as where
denotes the cardinality of a set.
In other words, rk(n) is the number of ways n can be written as a sum of k squares.
where each sum has two sign combinations, and also
with four sign combinations.
On the other hand,
because there is no way to represent 3 as a sum of two squares.
The number of ways to write a natural number as sum of two squares is given by r2(n).
It is given explicitly by where d1(n) is the number of divisors of n which are congruent to 1 modulo 4 and d3(n) is the number of divisors of n which are congruent to 3 modulo 4.
Using sums, the expression can be written as: The prime factorization
are the prime factors of the form
( mod
are the prime factors of the form
( mod
gives another formula Gauss proved that for a squarefree number n > 4, where h(m) denotes the class number of an integer m. There exist extensions of Gauss' formula to arbitrary integer n.[1][2] The number of ways to represent n as the sum of four squares was due to Carl Gustav Jakob Jacobi and it is eight times the sum of all its divisors which are not divisible by 4, i.e.
Representing n = 2km, where m is an odd integer, one can express
in terms of the divisor function as follows: The number of ways to represent n as the sum of six squares is given by where
is the Kronecker symbol.
[3] Jacobi also found an explicit formula for the case k = 8:[3] The generating function of the sequence
for fixed k can be expressed in terms of the Jacobi theta function:[4] where The first 30 values for
are listed in the table below: Grosswald, Emil (1985).
Representations of integers as sums of squares.
• | Squares (and thus integer distances) in red |
• | Non-unique representations (up to rotation and reflection) bolded |