Sorry about the lack of a MaBloWriMo post yesterday. I got a little behind, left resources I wanted at the office, and did some other things.

If you remember, my original goal in this process was to relate the Farey sequences to the Riemann hypothesis. I have some vague understanding that the relationship is based on the distribution of the terms in the Farey sequence, as points in the unit interval. It’s getting on toward time to talk about the Riemann hypothesis side of this picture, so I can start relating the two. But before I do, there’s one more diversion (hopefully it isn’t too far off base) I’d like to make related to Farey sequences. I’ve still got some learning to do about it, but let’s see what I can get down today, laying some foundation for the next day or two, perhaps.

Recall that the way to construct one Farey sequence, , from the previous one, , is to throw in all of the mediants of successive terms whose denominators aren’t too big. What if we didn’t bother with that last part, and just left in all the mediants? All the numbers we’ll write down are still reduced, and we’ll obtain all of the fractions in this way, because they all show up in some Farey sequence, and we’re getting all the terms in all the Farey sequences, just sometimes a little earlier than Farey would.

Just to be clear, our first few sequences now look like this:

and so on. We see that the -th sequence in this list contains all of , as well as some other numbers with bigger denominators. A nice property of these sequences, which isn’t shared with the Farey sequences, is that every other term in the -th sequence is a new term that wasn’t in the -st sequence. So when I go to make the next sequence in this process, I’m always taking the mediant of a “new” number and an “old” number. Moreover, each “new” number will be involved in two mediants… one taken “to the left” (with the “old” number on the left, making a smaller value) and one taken “to the right”.

This language let’s me write down a binary tree (every node has two branches down) as follows: Begin with 1/2 as the root (at the top, I’m throwing out 0/1 and 1/1). This is a new fraction in the second sequence above, so to make the third sequence, I added in the “left mediant” (1/3) and “right mediant” (2/3) from 1/2. To make the sequence after that, 1/3 gives a “left mediant” (1/4) and a “right mediant” (2/5), and similarly 2/3 spawns 3/5 and 3/4. So I build up a tree that looks like this:

I’ll call this the Stern-Brocot tree, though the actual definition my be slightly different.

Another way I could build up a sequence of sequences, and generate another binary tree, is to use midpoints, instead of mediants. If my first sequence is still 0/1 and 1/1, then taking midpoints will always give me denominators that are powers of 2. My tree will now look like:

I could now line up these trees, and determine a function that takes one rational number, finds it’s position in the first tree, and spits out the value in the same position from the second tree. For example, using our pictures above, we see that this function will take 3/5 to 5/8. This function is known as Minkowski’s question mark function, , and Wikipedia has a graph, so you should click that last link. I’ve only defined it on rationals, but you wave the “continuity” wand to extend my definition to a function on .

So, to evaluate for some rational, you have to find that rational in the Stern-Brocot tree. How do you do that? You know that you don’t have to go further down in the tree than your denominator, but that’s still a lot of fractions to look at, potentially. Perhaps there’s a better way?

I guess one way is to play the over-under game. Start at 1/2. If that’s your fraction, you are done. Otherwise, if your fraction is bigger, move right, and if your fraction is smaller, move left. Repeat until you get to your fraction.

But there’s more math we can say if we think about this process slightly differently.

The point of the tree being a tree is that there is only one way to get from the root, 1/2, to any fraction. Working your way down, you make a sequence of moves, either left () or right (). So you generate some string – , for example. Of course, that notation gets out of hand quickly, so we might also use exponents to write this example as . To such a string we can associate a sequence of fractions by writing down whatever fraction we are at when we change direction. Let us write this sequence as , and call these “turning points”. I’ve used primes here, because the numbers I’m actually interested in are one before I make a turn. Let me call that sequence , calling these values parents (so has a line directly down to in the Stern-Brocot tree, connecting the two). So, for example, the sequence has turning points , , and finally and associated parents , , and .

What is the relationship among successive turning points and parents? Suppose you are at the turning point , with parent , looking to get to the next parent or turning point, and are going to do this with a sequence of moves (left or right, it doesn’t actually matter). The next parent will be the weighted mediant of the turning point with its parent . That is, , and . Similarly, the next turning point will be the weighted mediant of with . This also means that it is the weighted mediant of with .

Combining all of these relationships, messing with the algebra just slightly, you can determine that and . You may recall that these are exactly the relations between the convergents of a continued fraction (if you start putting subscripts on your , writing it as ).

So, given a continued fraction for a rational in , begin at 1/1 (which isn’t in the tree, I know) and move left times (the first move getting you to 1/2), then move right, and so on. In your final step, you only move (if you wonder about the “-1″, you might think that the -th convergent is the fraction you are after, and that is the -th parent, not the -th turning point), and you’ll arrive at . On your way, all of the fractions that you hit, one before a turning point, will be the convergents to .

That only gets us half-way into evaluating , for this rational you’ve picked. You first find its continued fraction and then, by the process above, you’ll see how to get down to from the top of your tree. That means will be the value in our second tree (taking averages, the tree with powers of two in the denominator) that follows the same path. The initial lefts, from 1/1, will get us to a value of . Then we are supposed to take rights. Taking 1 right will get us to . Another right will then be , which I’ll write . Yet another right gets us to , and so on, until . After that, we move left times. The analysis of where we end up is basically the same, you just have to remember that you are subtracting s, instead of adding them.

Putting this all together, we obtain (remembering that in the last stage we only went moves.

Just as a warning, I may be off slightly in some of my formulas. I haven’t written down anything knowing that it was false, but I’m not convinced I obtain the correct formula at the end of the day (it looks slightly different from the formula at Wikipedia, for instance). If anybody sees an error, please let me know.

That’s probably plenty for today. Up next (I think), I want to take the derivative (even though I can’t) of , because Wikipedia thinks I’ll get something related to the density of the Farey sequences.

By the way, a paper I was looking at to figure out about these things was “The Minkowski Question Mark, and the Modular Group (Expository)” by Linas Vepstas. The printed copy I have, from some time summer 2009, is incomplete, but it looks to be available online.