Preply — Study more efficiently by working with a personal tutor. Get 50% off.Affiliate

Wikipedia

Fermat's theorem on sums of two squares

Fermat's theorem on sums of two squares

In additive number theory, Fermat's theorem on sums of two squares states that an odd prime p can be expressed as:

p = x 2 + y 2 , {\displaystyle p=x^{2}+y^{2},}

with x and y integers, if and only if

p ≡ 1 ( mod 4 ) . {\displaystyle p\equiv 1{\pmod {4}}.}

The prime numbers for which this is true are called Pythagorean primes. For example, the primes 5, 13, 17, 29, 37 and 41 are all congruent to 1 modulo 4, and they can be expressed as sums of two squares in the following ways:

5 = 1 2 + 2 2 , 13 = 2 2 + 3 2 , 17 = 1 2 + 4 2 , 29 = 2 2 + 5 2 , 37 = 1 2 + 6 2 , 41 = 4 2 + 5 2 . {\displaystyle 5=1^{2}+2^{2},\quad 13=2^{2}+3^{2},\quad 17=1^{2}+4^{2},\quad 29=2^{2}+5^{2},\quad 37=1^{2}+6^{2},\quad 41=4^{2}+5^{2}.}

On the other hand, the primes 3, 7, 11, 19, 23 and 31 are all congruent to 3 modulo 4, and none of them can be expressed as the sum of two squares. This is the easier part of the theorem, and follows immediately from the observation that all squares are congruent to 0 (if number squared is even) or 1 (if number squared is odd) modulo 4. Since the Diophantus identity implies that the product of two integers each of which can be written as the sum of two squares is itself expressible as the sum of two squares, by applying Fermat's theorem to the prime factorization of any positive integer n, we see that if all the prime factors of n congruent to 3 modulo 4 occur to an even exponent, then n is expressible as a sum of two squares. The converse also holds. This generalization of Fermat's theorem is known as the sum of two squares theorem.

History Albert Girard was the first to make the observation, characterizing the positive integers (not necessarily primes) that are expressible as the sum of two squares of positive integers; this was published in 1625. The statement that every prime p of the form 4 n + 1 {\displaystyle 4n+1} is the sum of two squares is sometimes called Girard's theorem. For his part, Fermat wrote an elaborate version of the statement (in which he also gave the number of possible expressions of the powers of p as a sum of two squares) in a letter to Marin Mersenne dated December 25, 1640: for this reason this version of the theorem is sometimes called Fermat's Christmas theorem.

Gaussian primes Fermat's theorem on sums of two squares is strongly related with the theory of Gaussian primes. A Gaussian integer is a complex number a + i b {\displaystyle a+ib} such that a and b are integers. The norm N ( a + i b ) = a 2 + b 2 {\displaystyle N(a+ib)=a^{2}+b^{2}} of a Gaussian integer is an integer equal to the square of the absolute value of the Gaussian integer. The norm of a product of Gaussian integers is the product of their norms. This is the Diophantus identity, which results immediately from the similar property of the absolute value. Gaussian integers form a principal ideal domain. This implies that Gaussian primes can be defined similarly as primes numbers, that is as those Gaussian integers that are not the product of two non-units (here the units are 1, −1, i and −i). The multiplicative property of the norm implies that a prime number p is either a Gaussian prime or the norm of a Gaussian prime. Fermat's theorem asserts that the first case occurs when p = 4 k + 3 , {\displaystyle p=4k+3,} and that the second case occurs when p = 4 k + 1 {\displaystyle p=4k+1} and p = 2. {\displaystyle p=2.} The last case is not considered in Fermat's statement, but is trivial, as 2 = 1 2 + 1 2 = N ( 1 + i ) . {\displaystyle 2=1^{2}+1^{2}=N(1+i).}

Related results The above point of view on Fermat's theorem is a special case of the theory of factorization of ideals in rings of quadratic integers. In summary, if O d {\displaystyle {\mathcal {O}}_{\sqrt {d}}} is the ring of algebraic integers in the quadratic field, then an odd prime number p, not dividing d, is either a prime element in O d , {\displaystyle {\mathcal {O}}_{\sqrt {d}},} or the ideal norm of an ideal of O d , {\displaystyle {\mathcal {O}}_{\sqrt {d}},} which is necessarily prime. Moreover, the law of quadratic reciprocity allows distinguishing the two cases in terms of congruences. If O d {\displaystyle {\mathcal {O}}_{\sqrt {d}}} is a principal ideal domain, then p is an ideal norm if and only

4 p = a 2 − d b 2 , {\displaystyle 4p=a^{2}-db^{2},}

with a and b both integers. In a letter to Blaise Pascal dated September 25, 1654 Fermat announced the following two results that are essentially the special cases d = − 2 {\displaystyle d=-2} and d = − 3. {\displaystyle d=-3.} If p is an odd prime, then

p = x 2 + 2 y 2 ⟺ p ≡ 1 or p ≡ 3 ( mod 8 ) , {\displaystyle p=x^{2}+2y^{2}\iff p\equiv 1{\mbox{ or }}p\equiv 3{\pmod {8}},}

p = x 2 + 3 y 2 ⟺ p ≡ 1 ( mod 3 ) . {\displaystyle p=x^{2}+3y^{2}\iff p\equiv 1{\pmod {3}}.}

Fermat wrote also:

If two primes which end in 3 or 7 and surpass by 3 a multiple of 4 are multiplied, then their product will be composed of a square and the quintuple of another square. In other words, if p, q are of the form 20k + 3 or 20k + 7, then pq = x2 + 5y2. Euler later extended this to the conjecture that

p = x 2 + 5 y 2 ⟺ p ≡ 1 or p ≡ 9 ( mod 20 ) , {\displaystyle p=x^{2}+5y^{2}\iff p\equiv 1{\mbox{ or }}p\equiv 9{\pmod {20}},}

2 p = x 2 + 5 y 2 ⟺ p ≡ 3 or p ≡ 7 ( mod 20 ) . {\displaystyle 2p=x^{2}+5y^{2}\iff p\equiv 3{\mbox{ or }}p\equiv 7{\pmod {20}}.}

Both Fermat's assertion and Euler's conjecture were established by Joseph-Louis Lagrange. This more complicated formulation relies on the fact that O − 5 {\displaystyle {\mathcal {O}}_{\sqrt {-5}}} is not a principal ideal domain, unlike O − 2 {\displaystyle {\mathcal {O}}_{\sqrt {-2}}} and O − 3 . {\displaystyle {\mathcal {O}}_{\sqrt {-3}}.}

Algorithm In 1990, Stan Wagon described a Las Vegas algorithm with a probabilistically polynomial complexity based on work by Serret and Hermite (1848), and Cornacchia (1908). The probabilistic part consists in finding a quadratic non-residue, which can be done with success probability ≈ 1 2 {\displaystyle \approx {\frac {1}{2}}} and then iterated if not successful. Conditionally this can also be done in deterministic polynomial time if the generalized Riemann hypothesis holds as explained for the Tonelli–Shanks algorithm.

Description Given an odd prime p {\displaystyle p} in the form 4 k + 1 {\displaystyle 4k+1} , first find x ∈ { 1 , … , p − 1 2 } {\displaystyle x\in \{1,\dots ,{\frac {p-1}{2}}\}} such that x 2 ≡ − 1 ( mod p ) {\displaystyle x^{2}\equiv -1{\pmod {p}}} . This can be done by finding a quadratic non-residue modulo p {\displaystyle p} , say q {\displaystyle q} , and letting

x = q p − 1 4 ( mod p ) {\displaystyle x=q^{\frac {p-1}{4}}{\pmod {p}}} . Such an x {\displaystyle x} will satisfy the condition since quadratic non-residues satisfy q p − 1 2 ≡ − 1 ( mod p ) {\displaystyle q^{\frac {p-1}{2}}\equiv -1{\pmod {p}}} . Once x {\displaystyle x} is determined, one can apply the Euclidean algorithm with p {\displaystyle p} and x {\displaystyle x} . Denote the first two remainders that are less than the square root of p {\displaystyle p} as a {\displaystyle a} and b {\displaystyle b} . Then it will be the case that a 2 + b 2 = p {\displaystyle a^{2}+b^{2}=p} .

Example Take p = 97 {\displaystyle p=97} . A possible quadratic non-residue for 97 is 13, since 13 97 − 1 2 ≡ − 1 ( mod 97 ) {\displaystyle 13^{\frac {97-1}{2}}\equiv -1{\pmod {97}}} . so we let x = 13 97 − 1 4 = 22 ( mod 97 ) {\displaystyle x=13^{\frac {97-1}{4}}=22{\pmod {97}}} . The Euclidean algorithm applied to 97 and 22 yields:

97 = 22 ( 4 ) + 9 , {\displaystyle 97=22(4)+9,}

22 = 9 ( 2 ) + 4 , {\displaystyle 22=9(2)+4,}

9 = 4 ( 2 ) + 1 , {\displaystyle 9=4(2)+1,}

4 = 1 ( 4 ) . {\displaystyle 4=1(4).}

The first two remainders smaller than the square root of 97 are 9 and 4; and indeed we have 97 = 9 2 + 4 2 {\displaystyle 97=9^{2}+4^{2}} , as expected.

Proofs Fermat usually did not write down proofs of his claims, and he did not provide a proof of this statement. The first proof was found by Euler after much effort and is based on infinite descent. He announced it in two letters to Goldbach, on May 6, 1747 and on April 12, 1749; he published the detailed proof in two articles (between 1752 and 1755). Lagrange gave a proof in 1775 that was based on his study of quadratic forms. This proof was simplified by Gauss in his Disquisitiones Arithmeticae (art. 182). Dedekind gave at least two proofs based on the arithmetic of the Gaussian integers. There is an elegant proof using Minkowski's theorem about convex sets. Simplifying an earlier short proof due to Heath-Brown (who was inspired by Liouville's idea), Zagier presented a non-constructive one-sentence proof in 1990. And more recently Christopher gave a partition-theoretic proof.

Euler's proof by infinite descent Euler succeeded in proving Fermat's theorem on sums of two squares in 1749, when he was forty-two years old. He communicated this in a letter to Goldbach dated 12 April 1749. The proof relies on infinite descent, and is only briefly sketched in the letter. The full proof consists in five steps and is published in two papers. The first four steps are Propositions 1 to 4 of the first paper and do not correspond exactly to the four steps below. The fifth step below is from the second paper. For the avoidance of ambiguity, zero will always be a valid possible constituent of "sums of two squares", so for example every square of an integer is trivially expressible as the sum of two squares by setting one of them to be zero. 1. The product of two numbers, each of which is a sum of two squares, is itself a sum of two squares.

This is a well-known property, based on the identity

( a 2 + b 2 ) ( p 2 + q 2 ) = ( a p + b q ) 2 + ( a q − b p ) 2 {\displaystyle (a^{2}+b^{2})(p^{2}+q^{2})=(ap+bq)^{2}+(aq-bp)^{2}}

due to Diophantus. 2. If a number which is a sum of two squares is divisible by a prime which is a sum of two squares, then the quotient is a sum of two squares. (This is Euler's first Proposition).

Indeed, suppose for example that a 2 + b 2 {\displaystyle a^{2}+b^{2}} is divisible by p 2 + q 2 {\displaystyle p^{2}+q^{2}} and that this latter is a prime. Then p 2 + q 2 {\displaystyle p^{2}+q^{2}} divides

p 2 ( a 2 + b 2 ) − a 2 ( p 2 + q 2 ) = p 2 b 2 − a 2 q 2 = ( p b − a q ) ( p b + a q ) . {\displaystyle p^{2}(a^{2}+b^{2})-a^{2}(p^{2}+q^{2})=p^{2}b^{2}-a^{2}q^{2}=(pb-aq)(pb+aq).}

Since p 2 + q 2 {\displaystyle p^{2}+q^{2}} is a prime, it divides one of the two factors. Suppose that it divides p b − a q {\displaystyle pb-aq} . Since

( a 2 + b 2 ) ( p 2 + q 2 ) = ( a p + b q ) 2 + ( a q − b p ) 2 {\displaystyle (a^{2}+b^{2})(p^{2}+q^{2})=(ap+bq)^{2}+(aq-bp)^{2}}

(Diophantus's identity) it follows that p 2 + q 2 {\displaystyle p^{2}+q^{2}} must divide ( a p + b q ) 2 {\displaystyle (ap+bq)^{2}} . So the equation can be divided by the square of p 2 + q 2 {\displaystyle p^{2}+q^{2}} . Dividing the expression by ( p 2 + q 2 ) 2 {\displaystyle (p^{2}+q^{2})^{2}} yields:

a 2 + b 2 p 2 + q 2 = ( a p + b q p 2 + q 2 ) 2 + ( a q − b p p 2 + q 2 ) 2 {\displaystyle {\frac {a^{2}+b^{2}}{p^{2}+q^{2}}}=\left({\frac {ap+bq}{p^{2}+q^{2}}}\right)^{2}+\left({\frac {aq-bp}{p^{2}+q^{2}}}\right)^{2}}

and thus expresses the quotient as a sum of two squares, as claimed. On the other hand if p 2 + q 2 {\displaystyle p^{2}+q^{2}} divides p b + a q {\displaystyle pb+aq} , a similar argument holds by using the following variant of Diophantus's identity:

( a 2 + b 2 ) ( q 2 + p 2 ) = ( a q + b p ) 2 + ( a p − b q ) 2 . {\displaystyle (a^{2}+b^{2})(q^{2}+p^{2})=(aq+bp)^{2}+(ap-bq)^{2}.}

3. If a number which can be written as a sum of two squares is divisible by a number which is not a sum of two squares, then the quotient has a factor which is not a sum of two squares. (This is Euler's second Proposition).

Suppose q {\displaystyle q} is a number not expressible as a sum of two squares, which divides a 2 + b 2 {\displaystyle a^{2}+b^{2}} . Write the quotient, factored into its (possibly repeated) prime factors, as p 1 p 2 ⋯ p n {\displaystyle p_{1}p_{2}\cdots p_{n}} so that a 2 + b 2 = q p 1 p 2 ⋯ p n {\displaystyle a^{2}+b^{2}=qp_{1}p_{2}\cdots p_{n}} . If all factors p i {\displaystyle p_{i}} can be written as sums of two squares, then we can divide a 2 + b 2 {\displaystyle a^{2}+b^{2}} successively by p 1 {\displaystyle p_{1}} , p 2 {\displaystyle p_{2}} , etc., and applying step (2.) above we deduce that each successive, smaller, quotient is a sum of two squares. If we get all the way down to q {\displaystyle q} then q {\displaystyle q} itself would have to be equal to the sum of two squares, which is a contradiction. So at least one of the primes p i {\displaystyle p_{i}} is not the sum of two squares. 4. If a {\displaystyle a} and b {\displaystyle b} are relatively prime positive integers then every factor of a 2 + b 2 {\displaystyle a^{2}+b^{2}} is a sum of two squares. (This is the step that uses step (3.) to produce an 'infinite descent' and was Euler's Proposition 4. The proof sketched below also includes the proof of his Proposition 3).

Let a , b {\displaystyle a,b} be relatively prime positive integers: without loss of generality a 2 + b 2 {\displaystyle a^{2}+b^{2}} is not itself prime, otherwise there is nothing to prove. Let q {\displaystyle q} therefore be a proper factor of a 2 + b 2 {\displaystyle a^{2}+b^{2}} , not necessarily prime: we wish to show that q {\displaystyle q} is a sum of two squares. Again, we lose nothing by assuming q > 2 {\displaystyle q>2} since the case q = 2 = 1 2 + 1 2 {\displaystyle q=2=1^{2}+1^{2}} is obvious. Let m , n {\displaystyle m,n} be non-negative integers such that m q , n q {\displaystyle mq,nq} are the closest multiples of q {\displaystyle q} (in absolute value) to a , b {\displaystyle a,b} respectively. Notice that the differences c = a − m q {\displaystyle c=a-mq} and d = b − n q {\displaystyle d=b-nq} are integers of absolute value strictly less than q / 2 {\displaystyle q/2} : indeed, when q > 2 {\displaystyle q>2} is even, gcd ( a , q / 2 ) = 1 {\displaystyle (a,q/2)=1} ; otherwise since gcd ( a , q / 2 ) ∣ q / 2 ∣ q ∣ a 2 + b 2 {\displaystyle (a,q/2)\mid q/2\mid q\mid a^{2}+b^{2}} , we would also have gcd ( a , q / 2 ) ∣ b {\displaystyle (a,q/2)\mid b} . Multiplying out we obtain

a 2 + b 2 = m 2 q 2 + 2 m q c + c 2 + n 2 q 2 + 2 n q d + d 2 = A q + ( c 2 + d 2 ) {\displaystyle a^{2}+b^{2}=m^{2}q^{2}+2mqc+c^{2}+n^{2}q^{2}+2nqd+d^{2}=Aq+(c^{2}+d^{2})}

uniquely defining a non-negative integer A {\displaystyle A} . Since q {\displaystyle q} divides both ends of this equation sequence it follows that c 2 + d 2 {\displaystyle c^{2}+d^{2}} must also be divisible by q {\displaystyle q} : say c 2 + d 2 = q r {\displaystyle c^{2}+d^{2}=qr} . Let g {\displaystyle g} be the gcd of c {\displaystyle c} and d {\displaystyle d} which by the co-primeness of a , b {\displaystyle a,b} is relatively prime to q {\displaystyle q} . Thus g 2 {\displaystyle g^{2}} divides r {\displaystyle r} , so writing e = c / g {\displaystyle e=c/g} , f = d / g {\displaystyle f=d/g} and s = r / g 2 {\displaystyle s=r/g^{2}} , we obtain the expression e 2 + f 2 = q s {\displaystyle e^{2}+f^{2}=qs} for relatively prime e {\displaystyle e} and f {\displaystyle f} , and with s < q / 2 {\displaystyle s<q/2} , since

q s = e 2 + f 2 ≤ c 2 + d 2 < ( q 2 ) 2 + ( q 2 ) 2 = q 2 / 2. {\displaystyle qs=e^{2}+f^{2}\leq c^{2}+d^{2}<\left({\frac {q}{2}}\right)^{2}+\left({\frac {q}{2}}\right)^{2}=q^{2}/2.}

Now finally, the descent step: if q {\displaystyle q} is not the sum of two squares, then by step (3.) there must be a factor q 1 {\displaystyle q_{1}} say of s {\displaystyle s} which is not the sum of two squares. But q 1 ≤ s < q / 2 < q {\displaystyle q_{1}\leq s<q/2<q} and so repeating these steps (initially with e , f ; q 1 {\displaystyle e,f;q_{1}} in place of a , b ; q {\displaystyle a,b;q} , and so on ad infinitum) we shall be able to find a strictly decreasing infinite sequence q , q 1 , q 2 , … {\displaystyle q,q_{1},q_{2},\ldots } of positive integers which are not themselves the sums of two squares but which divide into a sum of two relatively prime squares. Since such an infinite descent is impossible, we conclude that q {\displaystyle q} must be expressible as a sum of two squares, as claimed. 5. Every prime of the form 4 n + 1 {\displaystyle 4n+1} is a sum of two squares. (This is the main result of Euler's second paper).

If p = 4 n + 1 {\displaystyle p=4n+1} , then by Fermat's Little Theorem each of the numbers 1 , 2 4 n , 3 4 n , … , ( 4 n ) 4 n {\displaystyle 1,2^{4n},3^{4n},\dots ,(4n)^{4n}} is congruent to one modulo p {\displaystyle p} . The differences 2 4 n − 1 , 3 4 n − 2 4 n , … , ( 4 n ) 4 n − ( 4 n − 1 ) 4 n {\displaystyle 2^{4n}-1,3^{4n}-2^{4n},\dots

Tags

  • Additive number theory
  • Squares in number theory
  • Theorems in number theory