# Introduction

We began class by stating that our topic falls under the topic of Diophantine equations.

Definition:Adiophantine equationis any equation with one or more variable to be solved in the integers.

We then explained that integers can be written as sums of two squares, three squares, and even four squares. One of the most famous equation is the Pythagorean Theorem, which says $a^2 + b^2 = c^2$. Before we begin, we will show some examples.

**Example: Express 18 as a sum of two squares.**

$18 = 3^2 + 3^2$

**Example: Express 8 as a sum of two squares.**

$8 = 2^2 + 2^2$

**Example: Express 7 as a sum of two squares.**

$7 = 2^2 + 3$, but 3 cannot be expressed as a perfect square. Therefore, there is no solution.

# Sums of Two Squares

Proposition:Let $n_1, n_2 \in \mathbb{Z}$ with $n_1, n_2 > 0$. If $n_1$ and $n_2$ are expressible as the sums of two squares of integers, then $n_1, n_2$ is expressible as the sum of two squares of integers.

Proof: Let $x_1, y_1, x_2, y_2 \in \mathbb{Z}$ be such that $n_1 = x_1^2 + y_1^2$ and $n_2 = x_2^2 + y_2^2$. Then

(1)This can be expanded and seen as desired. $\square$

**Example: Express 144 as a sum of two squares.**

$144 = 18(8)$

From earlier examples, $18 = 3^2 + 3^2$ and $8 = 2^2 + 2^2$. Therefore,

Proof: Since $p \equiv 1 \mod{4}$, we know the legrende $(\frac{-1}{p}) = 1$. Thus exists $x \in \mathbb{Z}$, $0 < x ≤ (\frac{p-1}{2})$ such that $x^2 \equiv 1 \mod{p}$. Then $p\mid x^2 + 1$, giving us $x^2 + 1 = kp$, for some $k \in \mathbb{Z}$. Thus we know there is a solution to $x^2 + y^2 = kp$, by setting $y = 1$.

Also $kp = x^2 + y^2 < (\frac{p}{2})^2 + 1 < p^2$, implying $k < p$ as desired. $\square$

Proposition:If $p$ is a prime number such that $p \not \equiv 3 \mod{4}$, then $p$ is expressible as the sum of two squares of integers.

Proof: This will be a proof by contradiction. We are going to assume $p \equiv 1 \mod{4}$. By the lemma above, we know there exists an $m$ such that $x^2 + y^2 = mp$, when $0 < m < p$. We want $m = 1$, so we are going to assume $m > 1$. So we can write

(7)Then we can say $x^2 + y^2 = a^2 + b^2 = mp = 0 \mod{m}$.

Also by above lemma, we can say there exists a $k$ such that $a^2 + b^2 = kp$. So we can perform a multiplication by one trick: $(a^2 + b^2)(x^2 + y^2) = (km)(mp) = km^2p$.

By an earlier proposition, we can distribute and get $(ax + by)^2 + (ay - bx)^2 = km^2p$. We can substitute from earlier and get the following:

(9)Substituting back we get that $(\frac{ax + by}{m})^2 + (\frac{ay - bx}{m})^2 = \frac{km^2p}{m^2} = kp$. Since we know $\frac{-m}{2} < a, b < \frac{m}{2}$, we know that $a^2, b^2 < \frac{m^2}{4}$. Using equation above, $a^2 + b^2 = km < \frac{m^2}{4}$, so that means $k < \frac{m}{2} < m$ which contradicts the minimality of $m$. $\square$

**Example: Express 23 as a sum of two squares.**

Since $23 \equiv 3 \mod{4}$, by proposition, $23$ is not expressible as a sum of two squares.

**Example: Express 29 as a sum of two squares.**

Notice $29 \equiv 1 \mod{4}$. Therefore, by proposition, $29$ is expressible as the sum of two squares. With a little calculation, we get that $29 = 5^2 + 2^2$.

Now we are finally able to express these ideas as a theorem.

Theorem:Let $n \in \mathbb{Z}$ with $n > 0$. Then $n$ is expressible as the sums of two squares of integers if and only if every prime factor congruent to $3 \mod{4}$ occurs to an even power in the prime factorization of $n$.

Proof: (=>) Assume $p$ is an odd prime, and that $p^{2_i + 1}, i \in Z$, occurs in the prime factorization of $n$. We will show that $p \equiv 1 \mod{4}$. Since $n$ is expressible as the sum of two squares, there exists $x,y \in \mathbb{Z}$ such that $n = x^2 + y^2$.

Let $gcd(x,y) = d, a = \frac{x}{d}, b = \frac{y}{d}, m = \frac{n}{d^2}$, thus $gcd(a,b) = 1$. And $a^2 + b^2 = m$.

Let $p^j, j \in \mathbb{Z}$, be the largest power of $p$ dividing $d$. Then $p^(2_i+ 1 - 2_j) \mid m$ since $(2_i + 1) - 2_j ≥ 1$, we have $p \mid m$. Now $p$ cannot divide $a$ because if $p \mid a$, then $p \mid b$, and $gcd(a,b) \not = 1$.

By Theorem 2.6, there exists $z \in \mathbb{Z}$ such that $az \equiv b \mod{p}$ then

(11)Since $p \mid m$, we know that $a^2 (1+z^2) \equiv 0 \mod{p}$ And since $p$ cannot divide $a$ as stated above, $p \mid 1+z^2$ making $-1$ a quadratic residue modulo $p$. Therefore any odd prime factor occurring to an odd power in the prime factorization of $n$ must be congruent to 1 modulo 4. The contrapositive therefore insures that any prime factor congruent to 3 modulo 4 must happen to an even power.

(<=) This direction is much simpler, as we may assume every prime factor congruent to 3 modulo 4 occurs to an even power in the prime factorization of $n$. $n$ can then be written as $n = m^2p_1p_2...p_r$ with $m \in \mathbb{Z}$ and $p_1, p_2,…,p_r$ are distinct primes equal to 2 or congruent to 1 modulo 4. $m^2$ can clearly be written as a sum of two squares $(m^2 + 0^2)$, and by prop 6.7 each $p_i$ can be written as the sum of two squares. Adding prop 6.5 implies that $n$ is thus expressible as the sum of two squares. $\square$

**Example: Is 54 expressible as the sums of two squares?**

$54 = 2*33$ and therefore the answer is no since 3 is a prime factor congruent to 3 modulo 4 occurring to an odd power.

**Example: Is 162 expressible as the sums of two squares?**

$162 = 2*34$ and therefore the answer is yes, since 3 is the only prime factor congruent to 3 modulo 4 and it occurs to an even power.

# Sums of Three Squares

Now that we got a theorem that deals with expressing integers as the sum of two squares, we can move onto the sum of three squares case. The following proposition tells us whether or not an integer expressible as the sum of three squares, NOT how to express it.

Proposition:Let $m, n \in \mathbb{Z}$ with $m, n > 0$. If $N = 4^m(8n + 7)$, then $N$ is not expressible as the sum of three squares of integers.

Proof: This will be a proof by contradiction. We will assume $N$ is expressible as the sum of three squares. Assume $m = 0$.

(14)This implies $N \equiv 7 \mod{8}$. And since $N$ is expressible as a sum of three squares, we have the expression $8n + 7 = x^2 + y^2 + z^2$. But since $x^2 + y^2 + z^2 \not \equiv 7 \mod 8$, we have a contradiction.

Now assume $m > 0$. Again by assumption, $4^m(8n + 7) = x^2 + y^2 + z^2$. This implies $x, y, z$ must be even. Since even, there exists an $x, y, z$ such that $x = 2x', y = 2y', z = 2z'$.

(16)After applying induction $m - 1$ times, we would be able to see that $8n + 7$ is expressible as the sum of three squares, which is a contradiction. Therefore, $N = 4^m(8n + 7)$ is not expressible as the sum of three squares which ends our proof. $\square$

**Example: Determine whether 1472 is expressible as the sum of three squares.**

To find out, we have to see if $1472$ can be written in the form $4^m(8n + 7)$. Notice that the highest power of $4$ evenly dividing $1472$ is $64 (4^3)$. After dividing by $64$, we get $23$. After performing simple algebra, we see that $23 = 8(2) + 7$. Putting everything together, we see that $1472 = 43(8*2 + 7)$, which according to the proposition, cannot be expressed as the sum of three squares.

**Example: Determine whether 1584 is expressible as the sum of three squares.**

Again, we have to see if $1584$ can be written in the form $4^m(8n + 7)$. The highest power of $4$ evenly dividing $1584$ is $16 (4^2)$. This gives us $99$. After subtracting $7$, we get $92$, which cannot be evenly divided by $8$. Therefore since $1584$ cannot be written in the form $4^m(8n + 7)$, $1584$ can be written as the sum of three squares; however, we do not know exactly how to find it.

# Sums of Four Squares

So far, we have discussed the sum of two square case and the sum of three square case. The sum of four square case is important because eventually we’ll find out which integers are expressible as the sum of four squares.

Euler’s Proposition:Let $n_1, n_2 \in \mathhbb{Z}$ with $n_1, n_2> 0$. If $n_1$ and $n_2$ are expressible as the sums of four squares of integers, then $n_1n_2$ is expressible as the sum of four integers.

Proof:

Let $n_1 = w_1^2 +x_1^2 + y_1^2 + z_1^2$ and $n_2 = w_2^2 +x_2^2 + y_2^2 + z_2^2$. Then

After expansion and calculation, you get that $n_1n_2 = (-w_1y_2 + y_1w_2 + x_1z_2 - z_1x_2)^2 + (-w_1z_2 + z_1w_2 - x_1y_2 + y_1x_2)^2$. $\square$

**Example: Express 25 as the sum of four squares.**

Notice $25 = 5^2$. But since we want to express it as a sum of four squares, we write $25 = 5^2 + 0^2 + 0^2 + 0^2$.

**Example: Express 4 as the sum of four squares.**

There are a couple ways to write it. For purposes for the next example, we’ll write $4 = 1^2 + 1^2 + 1^2 + 1^2$. Can you find the other way?

**Example: Express 100 as the sum of four squares.**

Using the proposition above, we can write $100 = 4(25)$.

Euler’s Lemma:If $p$ is an odd prime number, then there exist $x, y \in \mathbb{Z}$ such that $x^2 + y^2 + 1 = kp$ where $k \in \mathbb{Z}$ and $0 < k < p$.

Proof: Two cases:

Case I: $p \equiv 1 \mod{4}$.

Then by setting $y = 0$, we have the same situation as proposition 6.7 of $x^2 + y^2 + 1 = kp$, and the proof is the same.

Case II: $p \equiv 3 \mod{4}$

Let $a$ be the least positive quadratic nonresidue modulo p. Note $a > 2$. Then the legrende symbol $(\frac{-a}{p}) = (\frac{-1}{p})(\frac{a}{p}) = (-1)(-1) = 1$. So there exists $x \in \mathbb{Z}$, with $0< x < \frac{p-1}{2}$ such that $x^2 \equiv -a \mod{p}$. Now take $a - 1$, which being positive and less than $a$, must be a quadratic residue modulo p, and so exists $y \in \mathbb{Z}$, with $0 < y < \frac{p-1}{2}$ such that $y^2 \equiv a-1 \mod{p}$.

Therefore $x^2 + y^2 + 1 \equiv (-a) + (a - 1) + 1 \equiv 0 \mod{p}$, which equivalently means that $x^2 + y^2 = kp$for some $k \in \mathbb{Z}$. Proving the existence of x and y to satisfy the desired equation.

Also $kp = x^2 + y^2 + 1 < (\frac{p}{2})^2 + (\frac{p}{2})^2 + 1 < p^2$. So $k < p$ as desired. $\square$

The proof of Euler’s lemma leads us to the case for all primes.

Proposition:All prime numbers are expressible as the sums of four squares of integers.

Proof: Assume $p$ to be an odd prime. Now let $m$ be the least positive integer such that $w^2 + x^2 + y^2 + z^2 = mp$ and $0 < m < p$. We need to show that $m = 1$. This will be another proof by contradiction. Assume $m > 1$. Now we will deal with cases.

Case I: $m$ is even.

If $m$ is even, then one of the three holds:

- $w, x, y, z$ is all even (since even plus even is even)
- $w, x, y, z$ is all odd (since odd plus odd is even)
- two is even and two is odd

WLOG, we’ll set $w \equiv x \mod{2}$ and $y \equiv z \mod{2}$. This implies

(24)which is a contradiction to the minimality of $m$. $\square$

Case II: $m$ is odd

Then $m > 3$. Let $a, b, c, d \in \mathbb{Z}$ such that

Then $a^2 + b^2 + c^2 + d^2 \equiv w^2 + x^2 + y^2 + z^2 = mp \equiv 0 \mod{m}$. And so exists $k \in \mathbb{Z}$ with $k> 0$ such that $a^2 + b^2 + c^2 + d^2 = km$.

Now $(a^2 + b^2 + c^2 + d^2)(w^2 + x^2 + y^2 + z^2) = (km)(mp) = km^2p$.

By prop 6.10 we have that

(29)Therefore

(34)Since $a \equiv w \mod{m}, b \equiv x \mod{m}, c \equiv y \mod{m}, d \equiv z \mod{m}$ we have

(35)Thus we can set $W, X, Y, Z \in \mathbb{Z}$ as

(39)And therefore $W^2 + X^2 + Y^2 + Z^2 = \frac{km^2p}{m^2} = kp$.

Since $\frac{-m}{2} < a < \frac{m}{2}, \frac{-m}{2} < b < \frac{m}{2}, \frac{-m}{2} < c < \frac{m}{2}, \frac{-m}{2} < d < \frac{m}{2}$, we know that $a^2 < \frac{m^2}{4}, b^2 < \frac{m^2}{4}, c^2 < \frac{m^2}{4}, d^2 < \frac{m^2}{4}$.

Making $km = a^2 + b^2 + c^2 + d^2 < 4(\frac{m^2}{4})$, which makes $k < m$. But $0 < k < m$ contradicts the minimality of $m$ for which $w^2 + x^2 + y^2 + z^2 = p$ is solvable. Therefore $m = 1$, completing the proof. $\square$

Now that we’ve dealt with all cases, the four-square theorem can now be stated and proved.

Lagrange’s Theorem:All positive integers are expressible as the sum of four squares of integers.

Proof: By above proposition, all primes are expressible as the sum of four squares. We also know that the product of two primes is composite. By Euler’s proposition, the product of two primes can be expressed as the sum of four squares, which implies that composite numbers are expressible as the sum of four squares. Therefore, all positive integers are expressible as the sum of four square integers. $\square$

**Example: Express 99 as a sum of four squares of integers.**

Using the same technique as above, $99 = 9(11)$

# Conclusion/Stuff to Think About

Other topics that this topic brings to interest:

Waring’s Problem:Let $k \in \mathbb{Z}$ with $k> 0$. Does there exist a minmum integer $g(k)$ such that every positive integer is expressible as the sum of at most $g(k)$ kth powers of nonnegative integers?

Hilbert Theorem proves that a $g(k)$ exists for all positive integers; however, the proof is nonconstructive, and therefore does not give a formula for $g(k)$.

15 Theorem:If an integral quadratic form with integral matrix represents all positive integers up to 15, then it represents all positive integers.