p-adic Numbers II: When Big is Small

Today we’ll finish our brief introduction to p-adic numbers.  It’s been a few weeks, so it couldn’t hurt to skim over the first post to refresh your memory.


After we finish our discussion of …..4444444, we’ll look at how to use ideas related to p-adic numbers to create fractal images like the one above.

Recall that our goal was to show that in the field of p-adic numbers, we had

.....444444444 = -1.

I should point out that the term field in mathematics has a very specific meaning, but we won’t be going into any more details about fields here.

In preparing to show this, we defined the 5-size of a number to be


where 5^q is the largest power of 5 which is a factor of n.  Although unconventional, this distance function satisfies all the necessary properties.

Here is where things get really interesting!  While thinking in terms of ordinary distance, it seems that the terms in the sequence of numbers

4, 44, 444, 4444, 44,\!444, \ldots

keep getting further and further apart.  But in terms of the 5-size, they actually get closer together.

Let’s see why.  The 5-distance between 4 and 44 is


since 5 is the largest power of 5 going into 40.  Recall that we’re working in base 5, so that in fact


So the highest power of 5 going into a number, written in base 5, is the number of 0’s at the end of that number.

Next, the distance between 44 and 444 is


since 5^2 is the largest power of 5 dividing 400.

Can you see where we’re going with this?  If you subtract a number with n fours from a number with n+1 fours, you get 4\cdot5^n, and so the 5-distance between them is |4\cdot5^n|_5=1/{5^n}. Therefore, as you keep adding fours, the numbers actually get closer and closer together when you consider the 5-size of their respective differences.

In mathematical terms, we say the sequence

4, 44, 444, 4444, 44,\!444, \ldots

converges with respect to the 5-distance, much as we say that 0.999999999..... converges with respect to the usual distance on real numbers.

What does this sequence converge to?  Suppose that

.....444444444 = L.

Let’s try to find L.  This is where addition modulo 5 comes in!  Consider the following addition problem:

\begin{tabular}{r}.....444444444\\1\\ \hline .....000000000\end{tabular}.

We’ll take a moment to interpret this sum.  On the very right (the units place), we add 1 + 4.  But that’s 5, and there is no digit “5” in base 5 — rather, we write “10.”  This means write down the 0, and carry the 1.  But then in the second column from the left (the 5’s place), we have 1+ 4 = 10, and so we write down the 0 and carry the 1.

As you can see, this process never ends, and the result is an infinite string of 0’s, which is 0.  This shows that

.....444444444 + 1 = 0,

or, in other words,

.....444444444 = -1!

And here’s the really mind-blowing part.  Consider the geometric series


in base 5.  The first term is 4, and the common ratio is 5.  So the sum is


Yes, the geometric series formula works when r is 5!  The reason is that when you keep multiplying numbers by 5 in the field of p-adic numbers, you’re really bringing them closer together.  Sounds impossible — but this can all be rigorously proved in the world of p-adic numbers.

Though we’ve only taken a small peek at the world of p-adic numbers, I’d like to take a few moments to say why they are significant when it comes to creating fractal images.  After all, that was the reason I found out about p-adic numbers in the first place!

On Day008, I discussed a way to determine which way you need to turn at any point during the construction of the Koch curve.  Here are the first few iterations of the Koch curve algorithm, in case you’ve forgotten.


In that post, I said I “discovered” that at step n, all you needed to do was look at the highest power of 2 going into n, and turn one way if that power was even, and another way if that power was odd.

But if you think about it for a moment, this is just what we did to calculate 5-size — found the highest power of one number which divides another number.  And if we just look at those exponents, we get what’s called a 5-adic valuation.  The first several terms look like this:


Any number not divisible by 5 has a valuation of 0, multiples of 5 have a valuation of at least 1, although for 25, you get 2.  And so on.

Actually, just a few weeks ago, I read in a paper I found online that the Koch curve can be generated by a 2-adic valuation.  As often happens in experimenting with mathematical ideas, you often re-discover ideas someone else already knew about.

I didn’t really care, though.  Doing mathematics is as much about the process as the result, and I really had fun “discovering” this, and writing my own proof showing how it generated the Koch curve.

So this got me thinking.  If you can generate fractal images with a 2-adic valuation, why not try a p-adic valuation for some value of p different from 2?

And to my amazement, it works in very much the same way!  But in order to generate a curve using two angles, you have to take the p-adic valuation, and then take it mod 2.  This generates a sequence of 0’s and 1’s, and that’s all you need.

I also found out that my work reproving an old result actually helped a lot — since I was able to prove a similar result for curves generated by a p-adic valuation in almost exactly the same way.  And my previous work already had me thinking about the relevant features of these new curves.  So when you discover some cool mathematical fact that someone else already knew, well, don’t despair.  Just entertain the thought that great minds think alike….


I’ve been experimenting a lot with p-adic valuations recently — this image is based on a 3-adic valuation.  I’ll only say that this opens up an entire new world of fractal image possibilities.  Check out my Twitter @cre8math for more cool examples!

p-adic Numbers I: When Big is Small

I can’t resist sharing something I just learned about this week.  p-adic numbers!  I discovered them while exploring angle sequences in creating Koch-like curves, and was immediately fascinated by them.  For example, we’ll see that in the field of 5-adic numbers,

.....444444444 = -1.

That’s right — the integer with infinitely many 4’s strung together is actually equal to -1!  This seems impossible at first glance, but is actually closely related to

0.999999999..... = 1

using decimal numbers.

The subject of p-adic numbers is a broad area in number theory, and we’ll only get a chance to  take a small glimpse into it.  The simplest examples to look at are related to geometric series.  We’ll briefly review them to refresh your memory.

Recall that

a+ar+ar^2+ar^3+\cdots ar^n+\cdots=\dfrac a{1-r}

when either a=0 or |r|<1.

When r=1, for example, the series


diverges.  To see this, we need to take the sequence of partial sums

2, 2+2, 2+2+2, 2+2+2+2,\ldots = 2, 4, 6, 8, \ldots,

which keeps getting larger and larger.  By contrast, the series


converges because the sequence of partial sums


keeps getting closer and closer to 2.  Of course we can verify the sum with the formula

\dfrac{a}{1-r}=\dfrac 1{1-1/2}=2.

The key idea behind discussing convergence is creating a precise mathematical definition of “getting closer and closer to.”  This is done using limits (we will not need to go into details here) and the distance function on the real numbers:


Intuitively, the absolute value of the difference between two numbers is an indication of how close they are.

For a sequence like

4, 44, 444, 4444, 44,\!444, \ldots,

which are the partial sums of the geometric series


it seems that the terms keep getting further and further apart:

d(444,4444)=4000,\quad d(4444,44,\!444)=40,\!000,....

In the field of p-adic numbers, closeness is measured a different way.  This might sound strange at first, but let’s consider closeness in plane geometry for a moment.

We are all familiar with the usual distance function in Euclidean geometry:


But maybe you weren’t aware that there are other ways to define distance in the plane — in fact, infinitely many ways — which give rise to non-Euclidean geometries.  One of the simplest is


This is often called the taxicab distance, since it describes how far it is from one point to another if you took a taxi on a rectangular grid of streets.

For example, consider going from (0,0) to (3,2) — we’ll use blocks as units — if you could only walk north, south, east, or west.  The shortest path might be to go east three blocks, and then north two blocks.  Or perhaps north one block, east three blocks, and then north one block again.  But the shortest path will always require that you walk five blocks, since you aren’t allowed to walk along a diagonal path.  (Note that the shortest path is not always unique in taxicab geometry!)

This is a perfectly legitimate geometry, with its own set of properties.  For example, the “unit circle” described by the equation


is in fact not a circle at all, but a square with vertices at a distance of 1 along the axes!


But not any function for distance will work — for example, you’ve got to make sure the triangle inequality is still valid (and it is in taxicab geometry).  So while some properties still need to hold, most other properties won’t.

What does this have to do with p-adic numbers?  We’re going to look at the positive integers for now, but define close in a very different way.  So we can look at some specific examples, let’s take p=5.

Here’s the big leap:  we say a positive integer is 5-small if there are many factors of 5 in its prime factorization.  More specifically, if q is the largest power of 5 which is a factor of n, then the we say that its 5-“size” is


Here are a few more examples, which you should be able to work out for yourself.

|42|_5=1,\quad |250|_5=\dfrac1{125},\quad |10^{100}|_5=5^{-100}.

But not everything big is small!  For example,


since there are no factors of 5 present (which is true for any number ending in a 1).

This may seem odd at first, but when you read more about it, it’s actually amazing. I’ll have to admit that to understand a lot of the amazingness, you’d have to go to grad school in mathematics….  But we’ll get to look at a litte bit of it here.

Before we do, though, there’s another role that 5 plays.  We’ve got to write 5-adic numbers in base 5.  There’s not room to go into all the details here, but we’ll give a brief review.

Recall that in base 10, we have


We can only use the digits 0–9.

Now in base 5, we can only use the digits 0–4, and we interpret the digits as follows:


We add the same way as we do in base 10, except we carry when we add to more than 5 (and not 10).  Thus,

4_5+3_5=12_5,\quad 34_5+12_5=101_5.

Subtraction, multiplication, and division are handled similarly.

You won’t need to be an expert in base-5 arithmetic in order to understand how this applies to the equation

.....444444444 = -1.

But that will have to wait for the next post on p-adic numbers!  We’ll see why this is true, and maybe even talk a little bit about rational p-adic numbers, too….