P-Adics

Some fun with p-adic number expansions

The modern world has discovered many odd kinds of new numbers. One of the strangest and most useful is the p-adic numbers, defined for any given prime number p as the "completion" of the rational numbers. The term "completion" here is being used in a technical sense explained here. These numbers turned out to be extremely important in quantum mechanics. The colors in the plot above have red, green, and blue components that correspond, respectively, to the 2nd, 3rd, and 4th digits in the p-adic expansion of the number you enter multiplied by the ratio of the x,y grid coordinates. We throw away the first digit because it is generally different from the successive ones and the repeating nature of the expansion only manifests in the second and later digits. So at location x=2, y=3 in the plot above and with the user entering numerator = 3, denominator = 5, and p = 7 we are looking at the 7-adic expansion of (3/5)*(2/3) or 2/5. The relevant digits in the 7-adic expansion of that number are 214 so the color at that point is red = 2/6, green = 1/6, and blue = 4/6. Note that the fractions are 6th's rather than 7th's reflecting the fact that, in a number system in base p there are only the digits (0,1,..., (p-1)). The value p itself is not represented by a digit. Multiplying these fractions by 255 to convert them into conventional 8 bit color fields we get a color of (85,42,170). Try different p, n, and d values and the plot will change accordingly. P-adic values tend to repeat after the first digit and many repeat on short cycles.