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.

6adicglow2

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

|n|_5=\dfrac1{5^q},

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

|44-4|_5=|40|_5=\dfrac15,

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

40_5=20_{10}.

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

|444-44|_5=|400|_5=\dfrac1{25},

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

4+40+400+4000+40,\!000+\cdots,

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

\dfrac{a}{1-r}=\dfrac4{1-5}=-1.

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.

Day007koch1

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:

0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,2,0,0,0,0,1,0,....

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….

2016-10-07-3adic.png

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

2+2+2+2+2+\cdots

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

1+\dfrac12+\dfrac14+\dfrac18+\cdots\dfrac1{2^n}\cdots

converges because the sequence of partial sums

1,1+\dfrac12,1+\dfrac12+\dfrac14,1+\dfrac12+\dfrac14+\dfrac18,\ldots=1,\dfrac32,\dfrac74,\dfrac{15}8,\ldots

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:

d(x,y)=|y-x|.

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

4+40+400+4000+40,\!000+\cdots,

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:

d((x_1,y_1),(x_2,y_2))=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}.

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

d_T((x_1,y_1),(x_2,y_2))=|x_2-x_1|+|y_2-y_1|.

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

d_T((x,y),(0,0))=|x|+|y|=1

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

taxicab

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

|n|_5=\dfrac1{5^q}.

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,

|10^{100}+1|_5=1,

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

5432_{10}=2+3\times10+4\times10^2+5\times10^3.

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:

4302_5=2+0\times5+3\times5^2+4\times5^3=577_{10}.

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….