---
title: "Lagrange's four-square theorem"
author: "cjc"
date: "2008-11-01T22:56:00Z"
tags: []
slug: "lagrange-s-four-square-theorem"
draft: false
lastmod: "2008-11-01T22:56:00Z"
id: 299054
url: "https://cjc.iteye.com/blog/299054"
---

### Lagrange's four-square theorem

### ([http://en.wikipedia.org/wiki/Lagrange%27s\_four-square\_theorem](http://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem))

**Lagrange's four-square theorem**, also known as **Bachet's conjecture**, was proven in 1770 by [Joseph Louis Lagrange](http://en.wikipedia.org/wiki/Joseph_Louis_Lagrange "Joseph Louis Lagrange"). An earlier proof by [Fermat](http://en.wikipedia.org/wiki/Fermat "Fermat") was never published.

The theorem appears in the [*Arithmetica*](http://en.wikipedia.org/wiki/Arithmetica "Arithmetica") of [Diophantus](http://en.wikipedia.org/wiki/Diophantus "Diophantus"), translated into Latin by [Bachet](http://en.wikipedia.org/wiki/Claude_Gaspard_Bachet_de_M%C3%A9ziriac "Claude Gaspard Bachet de Méziriac") in 1621. It states that every [positive](http://en.wikipedia.org/wiki/Negative_and_positive_numbers "Negative and positive numbers") [integer](http://en.wikipedia.org/wiki/Integer "Integer") can be expressed as the sum of four squares of integers. For example,

3 = 12 + 12 + 12 + 02

31 = 52 + 22 + 12 + 12

310 = 172 + 42 + 22 + 12.

More formally, for every positive integer n there exist integers *x*1, *x*2, *x*3, *x*4 such that

*n* = *x*12 + *x*22 + *x*32 + *x*42.

[Adrien-Marie Legendre](http://en.wikipedia.org/wiki/Adrien-Marie_Legendre "Adrien-Marie Legendre") improved on the theorem in 1798 by stating that a positive integer can be expressed as the sum of three squares [if and only if](http://en.wikipedia.org/wiki/If_and_only_if "If and only if") it is not of the form 4*k*(8*m* + 7). His proof was incomplete, leaving a gap which was later filled by [Carl Friedrich Gauss](http://en.wikipedia.org/wiki/Carl_Friedrich_Gauss "Carl Friedrich Gauss").

Lagrange's four-square theorem is a special case of the [Fermat polygonal number theorem](http://en.wikipedia.org/wiki/Fermat_polygonal_number_theorem "Fermat polygonal number theorem") and [Waring's problem](http://en.wikipedia.org/wiki/Waring%27s_problem "Waring's problem").

 

 

# Euler's four-square identity

([http://en.wikipedia.org/wiki/Euler%27s\_four-square\_identity](http://en.wikipedia.org/wiki/Euler%27s_four-square_identity))

[](http://en.wikipedia.org/wiki/Euler%27s_four-square_identity#searchInput) 

In [mathematics](http://en.wikipedia.org/wiki/Mathematics "Mathematics"), **Euler's four-square identity** says that the product of two numbers, each of which being a sum of four [squares](http://en.wikipedia.org/wiki/Square_%28algebra%29 "Square (algebra)"), is itself a sum of four squares. Specifically:

[Euler](http://en.wikipedia.org/wiki/Leonhard_Euler "Leonhard Euler") wrote about this identity in a letter dated [May 4](http://en.wikipedia.org/wiki/May_4 "May 4"), [1748](http://en.wikipedia.org/wiki/1748 "1748") to [Goldbach](http://en.wikipedia.org/wiki/Christian_Goldbach "Christian Goldbach")[\[1\]](http://en.wikipedia.org/wiki/Euler%27s_four-square_identity#cite_note-0)[\[2\]](http://en.wikipedia.org/wiki/Euler%27s_four-square_identity#cite_note-1) (but note that he used a different sign convention from the above). It can be proven with [elementary algebra](http://en.wikipedia.org/wiki/Elementary_algebra "Elementary algebra") and holds in every [commutative ring](http://en.wikipedia.org/wiki/Commutative_ring "Commutative ring"). If the *a**k* and *b**k* are [real numbers](http://en.wikipedia.org/wiki/Real_number "Real number"), a more elegant proof is available: the identity expresses the fact that the absolute value of the product of two [quaternions](http://en.wikipedia.org/wiki/Quaternion "Quaternion") is equal to the product of their absolute values, in the same way that the [Brahmagupta-Fibonacci two-square identity](http://en.wikipedia.org/wiki/Brahmagupta-Fibonacci_identity "Brahmagupta-Fibonacci identity") does for [complex numbers](http://en.wikipedia.org/wiki/Complex_numbers "Complex numbers").

The sign convention used above corresponds to the signs obtained by multiplying two quaternions. Other sign conventions can be obtained by changing any *a**k* to − *a**k*, *b**k* to − *b**k*, or by changing the signs inside any of the squared terms on the right hand side. For example, changing *a*1 to − *a*1, *b*1 to − *b*1, and changing the signs of the second, third, and fourth terms on the right hand side yields the alternate form:

The identity was used by [Lagrange](http://en.wikipedia.org/wiki/Joseph_Louis_Lagrange "Joseph Louis Lagrange") to prove his [four square theorem](http://en.wikipedia.org/wiki/Lagrange%27s_four-square_theorem "Lagrange's four-square theorem"). More specifically, it allows the theorem to be proven only for [prime numbers](http://en.wikipedia.org/wiki/Prime_numbers "Prime numbers").