Skip to main content
\( \newcommand{\lt}{ < } \newcommand{\gt}{ > } \newcommand{\amp}{ & } \)

Section13.1Some First Ideas

Subsection13.1.1A first pattern

Let's assume you've done some exploration on your own. Here's a first pattern that you may have noticed, similarly to patterns in the past.

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

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

In the next cell, I pick a number for which \(n\equiv 1\text{ (mod }4)\), but this number is not writeable. Thus Fact 13.1.1 doesn't just take care of all cases.

You can use this interact to avoid the errors.

Sage note13.1.3Handling errors

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.

Remark13.1.4

We have already addressed a very special case of writing numbers as a sum of squares. In fact, in Theorem 3.4.5 we saw a precise characterization of when a perfect square is a sum of two squares. We will mention this again briefly in Subsection 14.2.2.

Subsection13.1.2Geometry

Next, we can interpret this question very differently, relying on our geometric intuition. This graphic helps us visualize the problem.

In this graph, \(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.

Question13.1.5

  • Which circles around the origin have lattice points, and which ones do not?

  • If a circle has lattice points, how many does it have?

We will choose to address these questions by connecting to geometry. There are many ways; for instance, in Section 20.1 we will connect 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.

This sort of identity 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.

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.