Solving the Basel problem, using an elementary introduction to Fourier series!

Part 0: Motivation, some History, and Welcome!

Hello and welcome!

We are going to be tackling a beautiful problem, the ‘Basel Problem’. It was posed in 1650 by Pietro Mengoli, and it took 84 years to solve it, when the brilliant Euler did so.

Euler’s proof was brilliant, but also not strictly speaking complete! He used manipulations which couldn’t be justified with the mathematics developed at that time. It would take 100 years before the gaps in Euler’s proof were completely filled. …

Here we crack a tricky yet simple problem at the intersection of computer science and mathematics. It also gives a lovely insight into how to prove something is impossible.

Image for post
Image for post
Photo by Hassan Pasha on Unsplash

Statement and understanding

Let’s take a look at the chessboard below.

Image for post
Image for post

Here we investigate and understand the brilliant formula which unlocks the power of complex numbers.

First Impressions

Here’s a fun 2-minute guide to the infamous Axiom of Choice, one of the stranger mathematical curiosities.

Image for post
Image for post
By Fschwarzentruber — Own work, CC BY-SA 4.0,

What is the Axiom of Choice?

The short answer, not at all rigorous answer, is that the axiom of choice allows mathematicians to extract elements from an infinite number of infinitely large sets at once. This turns out to be very important, because mathematicians are very fond indeed of making infinite-sized things, and even more fond of being able to formalise their manipulations of infinite-sized things.

But let’s dig a little deeper.

The axiom of choice allows us to pick elements from ‘indexed sets’. When dealing with ‘finite things’, this seems kinda obvious. For instance, if A={1,2,3}, B={3,4,5}, and C={5,6}, then it is easy to pick an element from each. Just pick, say, 1 from A, 3 from B, and 6 from C. In fact, if you only every deal with finite sets (e.g. dealing with finite numbers, finite graphs, a finite number of people, etc…), then you will never need the Axiom of Choice. That includes lots of interesting maths, from computer science to graph theory. …

An intro to mathematical analysis, using ideas familiar to coders

Image for post
Image for post
Image attribution: By Stephan Kulla (User:Stephan Kulla) — Own work, CC BY-SA 4.0,

Sequences and convergence

A sequence of real numbers is simply a list of real numbers, where for any integer n, you are allowed to receive the nth number in the list. Fortunately, mathematicians deal in theoretical objects, so we never run out of memory, and never get stack overflows from recursive definitions.

A famous example of a sequence of real numbers is:

0.9, 0.99, 0.999, 0.9999, 0.99999, …

where the Nth number in the list has N nines following the zero.

We say this sequence ‘converges’ to 1. Why? The short and cheeky answer is to read the answer I wrote here. But I’ll explain again. The first term is only 0.1 away from 1, the second term is only 0.01 away from 1, and the Nth term is 0.00…01 away from one, where there are N zeros preceding the 1, i.e. …

Image for post
Image for post
Paul Erdős (1913–1996)

Let’s take a look at an unusual proof of the infinity of prime numbers.

Variations on Factorisation

By the Fundamental Theorem of Arithmetic, we can write any number as the product of primes. For example, 45 = 5*3², and 100 = 2²5²

A variation of this is that any number can be written as the product of a square-free number s and a square, , and this can be done uniquely. A square-free number is one where no perfect square divides it. I will call this the number’s sr² form.

For instance, 12 is not square-free, because 4 divides it. To get 12 into its sr² form we write 12 = 3*(2)² = sr², where s=3, and…

Over 2,300 years ago, Euclid proved the Fundamental Theorem of Arithmetic. Now it is our turn.

Image for post
Image for post
Some surviving fragments from Euclid’s Elements

Statement of the Theorem

The Fundamental Theorem of Arithmetic states that we can decompose any number uniquely into the product of prime numbers. For example, 350 = 2*7*5², and there is no other way to write 350 as the product of prime numbers.


Part I: Bezout’s Lemma

Bezout’s lemma tells us that, if two numbers a and b share no prime factors other than 1 and -1, then we can find q and s such that qa+sb=1.

Ok, let’s take some time to digest that with a worked example. Consider 7, and 9. The only numbers with divide 7 are {7,1,-1,-7}. The only numbers which divide 9 are {9,3,1,-1,-3,-9}. So, 7 and 9 share no prime factors. …

A visual proof of the Gauss Bonnet Theorem for triangles on spheres!

Spherical geometry is a beautiful, and very visual, area of mathematics, with weird properties (such as that the angles of triangles don’t sum to 180 !!!).

Understanding a little bit of Spherical Geometry

The Gauss-Bonnet Theorem for triangles on spheres is a special, but rather beautiful, case of the more general Gauss-Bonnet Theorem.

The theorem can be understood visually

First, let’s visualise what a triangle on a sphere is. Below are two visualisations of the same triangle.

Image for post
Image for post

When computer science and dynamic programming meets mathematics

Image for post
Image for post


This is the code heavy addendum to the more mathsy article I wrote on the Erdos-Szekeres Theorem. However, this is also self-contained, and is focused on finding monotone sequences rather than proving things about their size.

Our task is to write a program to find the longest increasing subsequence in a sequence of numbers. And then to visualise the results!

For instance, the longest increasing subsequence in [1,2,3,0,4] is [1,2,3,4].

The mathsy result is quite astonishing. …

A theorem by two mathematical greats, which anybody, no maths experience required, can understand! An amazing and beautiful result accompanied by some pretty hand-coded visualisations!

Image for post
Image for post
One of several visualisations. Own work, made using python3.8 and NetworkX

Regardless of your experience with math, this theorem can be understood, and the elegance of the solution appreciated. Throughout I will both use diagrams to explain concepts where possible. Where I use algebra notation like ‘x’ and ‘y’, I will also give concrete examples using real numbers so you can understand what is going on even if you aren’t comfortable with algebra.

Simple diagrams to explain complicated language

Before I state the problem, I want to build some understanding. That’s because the terms can be confusing to people who haven’t done much math, but by taking a little more time we can understand the problem without previous knowledge of any complicated language. If you are familiar with the terms used (in bold), then you can skip to the next section. …


Maths and Musings

I study Mathematics at Cambridge; I write about mathematics, and sometimes dream about it too. Hope to make hard math accessible.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store