Section13.1Some First Ideas

First, let's mention something that you should have noticed, based on our patterns in the past.

Subsection13.1.1Sage to the rescue

The next thing to note is that Sage has a nice command to tell us an answer.

If it doesn't exist, we get an error. If it does, Sage returns two numbers \((a,b)\) such that \(a^2+b^2=\) your number.

However, below I pick a number \(n\equiv 1\text{ mod }(4)\), but it is not writeable – so we can't just say that the Fact above takes care of all cases which can't be written as a sum of squares.

You can use this interact to avoid the errors.

Remark13.1.2

Sage note:
Most computer languages have a way to “handle” errors if we don't want to think of them as errors. In Python, this is the try/except syntax you see above. Basically, we are trying to use the two squares command, but if it hiccups, we instead just print a nice message.

Subsection13.1.2Geometry

Next, we can interpret this question very differently, relying on our geometric intuition.

This graphic helps us visualize the problem. If \(n=a^2+b^2\), then \(n\) is the square of the radius of a circle which has \((a,b)\) as the coordinates of a point. So the sum of squares problem is actually a geometric one!

That is, we can rewrite our questions like this:

  • Question: Which circles around the origin have lattice points, and which ones do not?
  • Question: If a circle has lattice points, how many does it have?

This is the way we'll choose to prove the questions, though there are many ways, connecting the problem to geometry. We will also see later how this function of how many ways there are to write a number as a sum of two squares leads us to calculus ideas in number theory.

Subsection13.1.3Connections to some very old mathematics

The following identity was, separately, already known to Diophantus (remember Diophantine equations?) around 250, to Brahmagupta (about whom more later) around 600, and to Leonardo of Pisa (known also as Fibonacci) around 1250. \[\left(a^2+b^2\right)\left(c^2+d^2\right)=\left(ac-bd\right)^2+\left(ad+bc\right)^2\] This may seem amazing to us, but to people used to needing lots of symbolic manipulation, it was just part of a toolkit by the time number theory began ascending with Fermat or Euler.

What is useful about this identity is that it implies the following.

Some books use the notation \(S_2\) to denote the set of numbers which can be written as a sum of squares, so another way to say this is \[\text{If }a,b\in S_2\text{, then }ab\in S_2\; .\]

A final question for the reader is to ponder why this means that we can really reduce the question to whether primes are writeable as a sum of squares.