Math 2.0

Number theory Proof

Proof of the sum of two squares theorem

Builds on Fermat's theorem on sums of two squaresBrahmagupta–Fibonacci identityP-adic valuationP-adic valuation of a productFirst supplement to quadratic reciprocityLegendre symbolQuadratic residueModular multiplicative inverseBézout's identityEuclid's lemmaEvery integer is a square times a square-free integerSquare-free integerExistence of prime factorizationMathematical induction

Proof

Let νp\nu_p be the p-adic valuation. Call nn a sum of two squares if n=x2+y2n = x^2 + y^2 with integers x,yx, y.

Lemma. Let p≡3(mod4)p \equiv 3 \pmod 4 be prime with p∣x2+y2p \mid x^2 + y^2. Then p∣xp \mid x and p∣yp \mid y.

  1. Suppose p∤yp \nmid y. Then gcd⁡(y,p)=1\gcd(y, p) = 1, and Bézout's identity gives a modular inverse ww with yw≡1(modp)yw \equiv 1 \pmod p.
  2. Multiplying x2+y2≡0x^2 + y^2 \equiv 0 by w2w^2 gives (xw)2≡−1(modp)(xw)^2 \equiv -1 \pmod p. So −1-1 is a quadratic residue modulo pp, and (−1p)=1\left(\frac{-1}{p}\right) = 1 as a Legendre symbol.
  3. But (p−1)/2(p - 1)/2 is odd, so the first supplement gives (−1p)=−1\left(\frac{-1}{p}\right) = -1. This contradiction shows p∣yp \mid y.
  4. Then p∣x2p \mid x^2, and p∣xp \mid x by Euclid's lemma.

If nn is a sum of two squares, then νp(n)\nu_p(n) is even for each prime p≡3(mod4)p \equiv 3 \pmod 4.

  1. Fix such a prime pp. We use strong induction on n≥1n \ge 1. Let n=x2+y2n = x^2 + y^2.
  2. If p∤np \nmid n, then νp(n)=0\nu_p(n) = 0, which is even.
  3. If p∣np \mid n, the lemma gives x=px′x = px' and y=py′y = py' with integers x′,y′x', y'. Then n=p2n′n = p^2 n' with n′=x′2+y′2n' = x'^2 + y'^2, and 1≤n′<n1 \le n' < n.
  4. By the induction hypothesis, νp(n′)\nu_p(n') is even. By the valuation of a product, νp(n)=2+νp(n′)\nu_p(n) = 2 + \nu_p(n') is even.

If νp(n)\nu_p(n) is even for each prime p≡3(mod4)p \equiv 3 \pmod 4, then nn is a sum of two squares.

  1. By the square times square-free decomposition, n=a2bn = a^2 b with positive integers aa, bb and bb square-free.
  2. Let p≡3(mod4)p \equiv 3 \pmod 4 be a prime. If p∣bp \mid b, then νp(b)=1\nu_p(b) = 1, as p2∤bp^2 \nmid b. Then νp(n)=2νp(a)+1\nu_p(n) = 2\nu_p(a) + 1 is odd, which is excluded. So p∤bp \nmid b.
  3. By existence of prime factorization, b=q1⋯qrb = q_1 \cdots q_r with primes qiq_i, where r≥0r \ge 0. By step 10, each qiq_i is 22 or a prime qi≡1(mod4)q_i \equiv 1 \pmod 4.
  4. Each qiq_i is a sum of two squares: 2=12+122 = 1^2 + 1^2, and the others by Fermat's theorem on sums of two squares.
  5. By the Brahmagupta–Fibonacci identity, a product of two sums of two squares is a sum of two squares. By induction on rr, bb is a sum of two squares. For r=0r = 0, b=1=12+02b = 1 = 1^2 + 0^2.
  6. Write b=u2+v2b = u^2 + v^2. Then n=a2b=(au)2+(av)2n = a^2 b = (au)^2 + (av)^2, a sum of two squares.

Idea

A prime p≡3(mod4)p \equiv 3 \pmod 4 cannot divide x2+y2x^2 + y^2 without dividing both xx and yy, because −1-1 is not a square modulo pp. So such primes come off in pairs. Conversely, the remaining primes are sums of two squares, and the Brahmagupta–Fibonacci identity multiplies them together.

Reading path

To understand this page from the ground up, read these 143 pages in order. The foundations come first. The path takes the proofs Proof of Bézout's identity, Proof of cancellation in an integral domain, Proof of the generalized Euclid's lemma, Proof of the commutativity of addition by induction, Proof of Fermat's little theorem by rearrangement, Proof that a composition of injections is injective, Proof of Fermat's theorem on sums of two squares by Thue's lemma, Proof of Euclid's lemma, Proof that R[x] is an integral domain iff R is, Proof of the Brahmagupta–Fibonacci identity, Proof that a function is bijective iff it has a two-sided inverse, Proof that every positive integer is a square times a square-free integer, Proof of the degree of a product over an integral domain, Proof of strong induction from ordinary induction, Proof that the p-adic valuation of a product is the sum of the valuations, Proof of the fundamental theorem of arithmetic, Proof of the complement principle, Proof that −1 is a square modulo p if and only if p is not 3 modulo 4, Proof of the pigeonhole principle, Proof that the integers modulo a prime form a field, Proof that a composition of surjections is surjective, Proof that congruence is compatible with addition, Proof of Euler's criterion by counting quadratic residues, Proof of the existence of prime factorization, Proof that a polynomial over a field has at most as many roots as its degree, Proof of the remainder theorem, Proof that congruence is compatible with multiplication, Proof of the rule of sum, Proof of the well-ordering principle from strong induction, Proof of the division algorithm, Proof of the first supplement to quadratic reciprocity from Euler's criterion, Proof of the bijection principle, Proof of the irrationality of square roots of non-squares, Proof of the factor theorem, Proof of the existence of a prime divisor, Proof that congruence is compatible with powers.

  1. Cardinality of a finite set definition
  2. Definition by recursion concept
  3. Divisibility definition
  4. Element definition
  5. Group concept
  6. Mathematical induction concept
  7. Natural numbers object
  8. Peano axioms concept
  9. Proposition concept
  10. Rational numbers object
  11. Real numbers object
  12. Congruence modulo n definition
  13. Greatest common divisor definition
  14. Prime number definition
  15. Set definition
  16. Ring definition
  17. Successor function definition
  18. Conjunction definition
  19. Implication definition
  20. Predicate definition
  21. Irrational number definition
  22. Modular multiplicative inverse definition
  23. Quadratic residue definition
  24. Residue class definition
  25. Coprime integers definition
  26. Proof that congruence is compatible with addition proof
  27. Proof that congruence is compatible with multiplication proof
  28. P-adic valuation definition
  29. Prime factorization definition
  30. Square-free integer definition
  31. Empty set object
  32. Ordered pair definition
  33. Addition of natural numbers definition
  34. Commutative ring definition
  35. Intersection definition
  36. Polynomial ring definition
  37. Ring homomorphism definition
  38. Unit of a ring definition
  39. Zero divisor definition
  40. The successor function is injective statement
  41. Zero is not a successor statement
  42. Existential quantifier definition
  43. Universal quantifier definition
  44. Legendre symbol definition
  45. Congruence is compatible with addition statement
  46. Congruence is compatible with multiplication statement
  47. Proof that every positive integer is a square times a square-free integer proof
  48. Proof of the commutativity of addition by induction proof
  49. Order on the natural numbers definition
  50. Subset definition
  51. Cartesian product definition
  52. Disjoint sets definition
  53. Divisibility in a commutative ring definition
  54. Proof of the Brahmagupta–Fibonacci identity proof
  55. Degree of a polynomial definition
  56. Field definition
  57. Polynomial evaluation definition
  58. Integral domain definition
  59. Uniqueness quantifier definition
  60. Proof that congruence is compatible with powers proof
  61. Integers modulo n definition
  62. Every integer is a square times a square-free integer statement
  63. Binary relation definition
  64. Commutativity of addition statement
  65. Brahmagupta–Fibonacci identity statement
  66. Proof of cancellation in an integral domain proof
  67. Proof of strong induction from ordinary induction proof
  68. Leading coefficient definition
  69. Root of a polynomial definition
  70. Evaluation homomorphism definition
  71. Congruence is compatible with powers statement
  72. Strong induction statement
  73. Monic polynomial definition
  74. Function definition
  75. Cancellation in an integral domain statement
  76. Multiplicity of a root definition
  77. Proof of the degree of a product over an integral domain proof
  78. Proof of the remainder theorem proof
  79. Codomain definition
  80. Function composition definition
  81. Identity function definition
  82. Injective function definition
  83. Image of a set definition
  84. Proof of the well-ordering principle from strong induction proof
  85. Division algorithm for polynomials statement
  86. Degree of a product statement
  87. Left inverse definition
  88. Right inverse definition
  89. Surjective function definition
  90. Proof that a composition of injections is injective proof
  91. Well-ordering principle statement
  92. Remainder theorem statement
  93. Proof that R[x] is an integral domain iff R is proof
  94. Proof that a composition of surjections is surjective proof
  95. Composition of injections is injective statement
  96. Bijective function definition
  97. Proof of the existence of a prime divisor proof
  98. Proof of the division algorithm proof
  99. Proof of the factor theorem proof
  100. R[x] is an integral domain iff R is statement
  101. Composition of surjections is surjective statement
  102. Proof that a function is bijective iff it has a two-sided inverse proof
  103. Existence of a prime divisor statement
  104. Division algorithm statement
  105. Proof of the rule of sum proof
  106. Factor theorem statement
  107. Bijective iff it has a two-sided inverse statement
  108. Rule of sum statement
  109. Proof of Bézout's identity proof
  110. Proof of the existence of prime factorization proof
  111. Proof that a polynomial over a field has at most as many roots as its degree proof
  112. Proof of the bijection principle proof
  113. Bézout's identity statement
  114. Proof of the complement principle proof
  115. Existence of prime factorization statement
  116. A polynomial over a field has at most as many roots as its degree statement
  117. Bijection principle statement
  118. Complement principle statement
  119. Proof of the generalized Euclid's lemma proof
  120. Proof that the integers modulo a prime form a field proof
  121. Integers modulo a prime form a field statement
  122. Proof of the pigeonhole principle proof
  123. Generalized Euclid's lemma statement
  124. Pigeonhole principle statement
  125. Proof of Euclid's lemma proof
  126. Euclid's lemma statement
  127. Proof of Fermat's little theorem by rearrangement proof
  128. Proof of the fundamental theorem of arithmetic proof
  129. Proof that the p-adic valuation of a product is the sum of the valuations proof
  130. Fermat's little theorem statement
  131. Fundamental theorem of arithmetic statement
  132. P-adic valuation of a product statement
  133. Proof of Euler's criterion by counting quadratic residues proof
  134. Proof of the irrationality of square roots of non-squares proof
  135. Euler's criterion statement
  136. Irrationality of square roots of non-squares statement
  137. Proof of the first supplement to quadratic reciprocity from Euler's criterion proof
  138. First supplement to quadratic reciprocity statement
  139. Proof of Fermat's theorem on sums of two squares by Thue's lemma proof
  140. Proof that −1 is a square modulo p if and only if p is not 3 modulo 4 proof
  141. −1 is a square modulo p if and only if p is not 3 modulo 4 statement
  142. Fermat's theorem on sums of two squares statement
  143. Proof of the sum of two squares theorem proof

Where this leads

1 page builds on this one.

Further reading

  1. Web https://wstein.org/ent/ent.pdf, Section 5.7, Theorem 5.7.1
About this page
Tag4XAHPWNPM3
URIm2://4XAHPWNPM3
Kindproof
WritingW0 stub
MSC11E25
ProvesSum of two squares theorem
UsesFermat's theorem on sums of two squares, Brahmagupta–Fibonacci identity, P-adic valuation, P-adic valuation of a product, First supplement to quadratic reciprocity, Legendre symbol, Quadratic residue, Modular multiplicative inverse, Bézout's identity, Euclid's lemma, Every integer is a square times a square-free integer, Square-free integer, Existence of prime factorization, Mathematical induction
Changed4 November 2026

Markdown · JSON · Edit on GitHub

What this page needs for W1

  • an inventory row: the row of the inventory that the node accounts for (0 of 1)

The writing levels say how complete the text of a page is. They do not measure its truth.

What links here

No page links to this page yet.