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

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

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 is the largest power of 5 dividing 400.

Can you see where we’re going with this? If you subtract a number with fours from a number with fours, you get and so the 5-distance between them is 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

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

What does this sequence converge to? Suppose that

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

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

or, in other words,

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!