In
number theory
Number theory is a branch of pure mathematics devoted primarily to the study of the integers and arithmetic functions. Number theorists study prime numbers as well as the properties of mathematical objects constructed from integers (for example ...
, the sum of squares function is an
arithmetic function
In number theory, an arithmetic, arithmetical, or number-theoretic function is generally any function whose domain is the set of positive integers and whose range is a subset of the complex numbers. Hardy & Wright include in their definition th ...
that gives the number of representations for a given positive
integer
An integer is the number zero (0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number (−1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative in ...
as the sum of
squares
In geometry, a square is a regular polygon, regular quadrilateral. It has four straight sides of equal length and four equal angles. Squares are special cases of rectangles, which have four equal angles, and of rhombuses, which have four equal si ...
, 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 .
Definition
The
function is defined as
:
where
denotes the
cardinality
The thumb is the first digit of the hand, next to the index finger. When a person is standing in the medical anatomical position (where the palm is facing to the front), the thumb is the outermost digit. The Medical Latin English noun for thum ...
of a
set
Set, The Set, SET or SETS may refer to:
Science, technology, and mathematics Mathematics
*Set (mathematics), a collection of elements
*Category of sets, the category whose objects and morphisms are sets and total functions, respectively
Electro ...
. In other words, is the number of ways can be written as a sum of squares.
For example,
since
where each sum has two sign combinations, and also
since
with four sign combinations. On the other hand,
because there is no way to represent 3 as a sum of two squares.
Formulae
''k'' = 2

The number of ways to write a
natural number
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
as sum of two squares is given by . It is given explicitly by
:
where is the number of
divisors of which are
congruent
Congruence may refer to:
Mathematics
* Congruence (geometry), being the same size and shape
* Congruence or congruence relation, in abstract algebra, an equivalence relation on an algebraic structure that is compatible with the structure
* In modu ...
to 1
modulo
In computing and mathematics, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another, the latter being called the '' modulus'' of the operation.
Given two positive numbers and , mo ...
4 and is the number of divisors of which are congruent to 3 modulo 4. Using sums, the expression can be written as:
:
The prime
factorization
In mathematics, factorization (or factorisation, see American and British English spelling differences#-ise, -ize (-isation, -ization), English spelling differences) or factoring consists of writing a number or another mathematical object as a p ...
, where
are the
prime factors of the form
and
are the prime factors of the form
gives another formula
:
, if ''all'' exponents
are
even. If one or more
are
odd, then
.
''k'' = 3
Gauss proved that for a
squarefree number ,
:
where denotes the
class number of an integer .
There exist extensions of Gauss' formula to arbitrary integer .
''k'' = 4
The number of ways to represent 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 , where ''m'' is an odd integer, one can express
in terms of the
divisor function
In mathematics, and specifically in number theory, a divisor function is an arithmetic function related to the divisors of an integer. When referred to as ''the'' divisor function, it counts the ''number of divisors of an integer'' (includi ...
as follows:
:
''k'' = 6
The number of ways to represent as the sum of six squares is given by
:
where
is the
Kronecker symbol.
''k'' = 8
Jacobi also found an
explicit formula for the case :
:
Generating function
The
generating function
In mathematics, a generating function is a representation of an infinite sequence of numbers as the coefficients of a formal power series. Generating functions are often expressed in closed form (rather than as a series), by some expression invo ...
of the
sequence
In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is cal ...
for fixed can be expressed in terms of the
Jacobi theta function
In mathematics, theta functions are special functions of several complex variables. They show up in many topics, including Abelian varieties, moduli spaces, quadratic forms, and solitons. Theta functions are parametrized by points in a tube do ...
:
:
where
:
Numerical values
The first 30 values for
are listed in the table below:
See also
*
Integer partition
In number theory and combinatorics, a partition of a non-negative integer , also called an integer partition, is a way of writing as a summation, sum of positive integers. Two sums that differ only in the order of their summands are considered ...
*
Jacobi's four-square theorem
*
Gauss circle problem
References
Further reading
External links
*
*
*{{cite OEIS, A004018, Theta series of square lattice, r_2(n)
Arithmetic functions
Squares in number theory
Integer factorization algorithms