four-squaretheorem(lagrange)
Four-Square Theorem (Lagrange)
Any positive integer can be written as the sum of four squares.
Proof:
From Lemma 1 (Euler) and Lemma 2, by induction.
Lemma 1
If the integers m and n are each the sum of four squares, then mn is also.
Proof:
m=a1**2+a2**2+a3**2+a4**2, n=b1**2+b2**2+b3**2+b4**2
mn=(a1**2+a2**2+a3**2+a4**2)(b1**2+b2**2+b3**2+b4**2)
=(a1b1+a2b2+a3b3+a4b4)**2+(a1b2-a2b1+a3b4-a4b3)**2+(a1b3-a2b4-a3b1+a4b2)**2+(a1b4+a2b3-a3b2-a4b1)**2
Lemma 2
Any prime p can be written as the sum of four squares.
Proof:
2=1**2+1**2+0**2+0**2