# Example: Ford circle

Published 2009-03-09 | Author: Alain Matthes

According to Wikipedia, a Ford circle is a circle with center at (p/q, 1/(2q^2)) and radius 1/(2q^2), where p/q is an irreducible fraction, i.e. p and q are coprime integers.

There is an interesting connection between the Farey sequence and Ford circles. The following graphic is based on the simple algorithm found in the Wikipedia Faray sequence entry. More information about Ford circles can be found at Mathworld.

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Wikipedia : In mathematics, a Ford circle is a circle with centre at (p/q, 1/(2q^2)) and
% radius 1/(2q^2), where p/q is an irreducible fraction, i.e. p and q are coprime
% integers.
% There is an interesting connection between Farey sequence and Ford circles.
% The following graphic is based on the Simple algorithm that you can find here
% http://en.wikipedia.org/wiki/Farey_sequence
% interesting information can be found here
% http://mathworld.wolfram.com/FordCircle.html

\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\newcommand{\drawcircle}[3]{%
\pgfmathparse{1/(2*#2*#2)}
}

\begin{document}

\def\fordN{5}
\def\fordA{0}
\def\fordB{1}
\def\fordC{1}
\let\fordD\fordN
\begin{center}\begin{tikzpicture}[scale=4]

\drawcircle{\fordA}{\fordB}{red}
\foreach \i/\c in
{0/blue,1/yellow,2/green,3/magenta,
4/orange,5/magenta,6/green,7/yellow,8/blue,9/red}{%
\pgfmathparse{\fordN+\fordB}\global\let\fordK\pgfmathresult
\pgfmathparse{floor(\fordK/\fordD)}\global\let\fordK\pgfmathresult
\pgfmathparse{\fordK*\fordC}\global\let\fordE\pgfmathresult
\pgfmathparse{\fordE-\fordA}\global\let\fordE\pgfmathresult
\pgfmathparse{\fordK*\fordD}\global\let\fordF\pgfmathresult
\pgfmathparse{\fordF-\fordB}\global\let\fordF\pgfmathresult
\global\let\fordA\fordC
\global\let\fordB\fordD
\global\let\fordC\fordE
\global\let\fordD\fordF
\drawcircle{\fordA}{\fordB}{\c}
}

\end{tikzpicture}\end{center}
\end{document}
% name Ford Circle
% utf8
% pdflatex
% author Alain Matthes


• #1 Hallucinator, July 13, 2010 at 6:12 p.m.

Awesome!

• #2 Doug, November 3, 2012 at 1:11 a.m.

Very good written post. It will be beneficial to everyone who employess it, as well as yours truly :). Keep doing what you are doing - can'r wait to read more posts.

• #3 Louann, November 3, 2012 at 3:48 a.m.

Hey would you mind stating which blog platform you're working with? I'm planning to start my own blog in the near future but I'm having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I'm looking for something unique. P.S Sorry for being off-topic but I had to ask!

• #4 Beatris, November 11, 2012 at 11:32 p.m.

It is the best time to make a few plans for the long run and it's time to be happy. I have learn this post and if I may just I desire to recommend you few attention-grabbing issues or tips. Maybe you could write next articles regarding this article. I desire to read even more issues about it!

• #5 Karolyn, November 15, 2012 at 8:09 a.m.

excellent points altogether, you just gained a brand new reader. What would you suggest in regards to your post that you made some days ago? Any positive?

• #6 Devin, November 18, 2012 at 8:44 p.m.

I loved as much as you will receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get got an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly very often inside case you shield this hike.

• #7 Issac, November 23, 2012 at 6:25 p.m.

I am curious to find out what blog platform you happen to be working with? I'm having some small security issues with my latest site and I'd like to find something more secure. Do you have any recommendations?

• #8 Nickolas, November 24, 2012 at 6:47 p.m.

Heya i am for the primary time here. I came across this board and I in finding It truly useful & it helped me out much. I'm hoping to provide something back and aid others such as you helped me.

• #9 Gregory, November 28, 2012 at 10:27 a.m.

Hey! I know this is somewhat off topic but I was wondering which blog platform are you using for this website? I'm getting fed up of Wordpress because I've had issues with hackers and I'm looking at options for another platform. I would be awesome if you could point me in the direction of a good platform.

• #10 Niki, January 22, 2013 at 2:40 a.m.

Wow, wonderful blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is excellent, as well as the content!