Ford gets Complex!



Not too complicated and just a different view of Ford’s circles and a way of morphing
them along with a bit of animation.

It’s a continuation of the previous post and there are two parts to it – the real bit and the imaginary part.

The Real Part

To start with we take fractions not between 0 and 1 but rather between -n and n. A rough and ready way is

where we take all possible pairs and reduce them. Note we allow 0 as a denominator so as to be consistent with the Farey sequence.

For example

The snippets of code below will take a list of Fraction and generate Ford circles.

The key function is makeCircles – notice that its signature is
makeCircles :: ([FordCircle] -> [FordCircle]) -> [Fraction] -> Picture

It takes a function that maps [FordCircle] to [FordCircle]. The purpose of this will be shown later – at the moment we can just use the identity function so that it has no effect on the list of FordCircle. And, using the identity function and polishing to a Gloss finish we can write:

with output:

Very much like the Ford circles in the previous post but ‘longer’. Now the for the

Imaginary Part

With a suitable import (Data.Complex) we can quite easily use Complex numbers in Haskell code and doing so often makes things simpler.

Here z is a Complex number consisting of a Real and Imaginary part – i.e. x + iy and the function fz is a particular type of complex function (Mobius Transform) that will map a circle onto another circle. Taking a list of circles we can determine three points on the circle, apply fz to each point and then determine the new circle that lies on those three points. (Does anyone know if there’s a simpler or better way to do this?) i.e.


In the function planeMap z1, z2 and z3 are all on the circle and their image under fz is used to determine a new circle. The function makeCircle is just an exercise in coordinate geometry. Now we can invoke makeCircles but this time give it planeMap rather than the id function.

Here we have the original set of circles and above them, the result of the transform šŸ™‚

To get the animation shown at the beginning we define another complex function, fzz (naming things is difficult…)

When the Float value in fzz is 1.0 then fzz is a Mobius Transform – it is identical to our first fz function. When the Float value is not 1.0 then I’m not sure it has a particular name, its just a mapping šŸ™‚ We can apply it along with the animation capability of Gloss to create a ‘morphing’ of the Ford circles into the final disk.


which produce the animation at the top of the page.


For added fun we can just let the value of step that get passed into planeMap’ increase unbounded and see how the original line of circles morphs into something intriguing…


All the code is in Github and thanks for reading!


Leave a Reply

Your email address will not be published. Required fields are marked *

ˆ Back To Top