I became interested in the patterns in multiplication tables for different base number systems a while ago. Specifically, the pattern made by the last digit of each number in the multiplication table. So, base 10 would look like this:


I thought it was interesting that when you move to number systems with different bases, the patterns don't follow the number. They follow it's relative position in the number system. E.g., in base 12, the pattern is 6,0,6,0,6......


I then realized, I could see the pattern better if I just assigned each number a color. I started with using 10 greyscale colors, with 0 being black and 9 being white. So now base 10 looks like this:

Base 10 in color form

Then, I figured that I really could use as many colors as I wanted to, and see if a larger pattern forms. Using all 256 greyscale colors, I came up with this image representing a base 256 multiplication table:

Base 256 greyscale

Or I could go from black to white to black, and smooth out the image:

Base 511 greyscale


I decided to animate the pattern to better see what was going on. To do this, I defined my 1-n color scale as [w,w,w,w,b,b,b,b,b,b,b,b....]. Where w is white and b is black. I would create a frame, shift my colors down one [b,w,w,w,w,b,b,b,b,b,b,b....], and create the next frame. I repeated this until they colors fully cycled and got this animated image.

Here's a site where you can modify the settings.

What is this pattern called?

My question is, what is this pattern called? I'm having a hard time finding anything about it. It seems to be a bunch of hyperbolic curves imposed on each other. There is a bunch of "stars" at the corners of where you would divide the image into 4ths, 9ths, etc.

Any insight into this would be appreciated.

  • 22
    $\begingroup$ This pattern is called "cool". $\endgroup$ – Lee Mosher Apr 25 '15 at 16:42
  • 5
    $\begingroup$ I'm not an expert, but look at moire patterns. $\endgroup$ – Bob Krueger Apr 25 '15 at 16:46
  • 1
    $\begingroup$ @Bob1123 It does seem similar to a moire pattern. But if it is, the question becomes what patterns are making up this pattern! $\endgroup$ – Alex McKenzie Apr 25 '15 at 16:50
  • 1
    $\begingroup$ Should the question title be changed to "What is the visual pattern in the multiplication table of modular arithmetic?" The OP didn't mention modular arithmetic but it does make this question easier to search for $\endgroup$ – jkabrg Apr 25 '15 at 17:08
  • 2
    $\begingroup$ I love that you posted this! I stumbled across this same pattern years ago but didn't think to ask about it online. (Then again, that might have been before I knew about Math.SE.) So, thanks for doing this! :) $\endgroup$ – El'endia Starman Apr 26 '15 at 0:28

What you've discovered is essentially modular arithmetic. By looking at only the last digits of a product (in whatever base you're looking at at the moment), you're in effect saying 'I don't care about things that differ by multiples of $n$; I want to consider them as the same digit'. For instance, in base $7$, $5\times 2=10_{10}=13$ has the same last digit as $4\times 6=24_{10}=33$; we put both of these numbers into a bucket labeled '$[3]$', along with $3$, $23=17_{10}$, $43=31_{10}$, etc. In mathematics, when we talk about $31 \bmod 7$ we sometimes just mean the number $3$ itself (that is, the 'label' on this bucket that's between $0$ and $6$, but it's often convenient to think of it as representing the whole bucket: whatever number we pick out of the $[3]$ bucket, when we add it to a number in the $[2]$ bucket, we know that our result will be in the $[5]$ bucket, and when we multiply a number in the $[3]$ bucket by a number in the $[4]$ bucket, we know that our result will be in the $[5]$ bucket; etc. "Last digits" are just a convenient way of talking about these buckets (though things get a little sketchier when you talk about negative numbers - note that according to these rules, $-3$ goes into the $[4]$ bucket!).

Meanwhile, the bands in your pattern are actually (pieces of) hyperbolas. Since $a\times (n-b)\equiv -(a\times b)\pmod n$ (the statement '$x=y\pmod n$' is a mathematical way of phrasing '$x$ and $y$ are in the same bucket in base $n$'; here, the difference between $a\times (n-b)$ and $-(a\times b)$ is $a\times n$), the far right hand side is essentially a reflection of the left, and similarly the bottom is a reflection of the top. If you rearrange the four quarters of your square so that the center of symmetry is (what was previously) the top left corner — i.e., take $A\ B\atop C\ D$ to $D\ C\atop B\ A$ — and then put the origin at the center, then the bands will exactly be (scaled versions) of the hyperbolae $xy=C$ (which are the hyperbolae $y^2-x^2=2C$ rotated by $45^\circ$). This happens because each 'cycle' of black-to-white or black-to-white-to-black will be separated by one multiple of $n$; e.g., the first transition between cycles occurs along the hyperbola $xy=n$; the second along the hyperbola $xy=2n$; etc.

(As for the moiré patterns, they're related to the usual way that such patterns are generated, and in particular they're somewhat related to aliasing near the Nyquist limit when the frequency between hyperbolic bands starts coming close to the frequency of the 'pixels' you're sampling with, but that's another story altogether...)

  • $\begingroup$ So could you say our base 10 number systyem (or any base number system) can be described with modular arithmetic? And is this pattern called anything specific? E.g., modulus pattern? $\endgroup$ – Alex McKenzie Apr 25 '15 at 17:10
  • 1
    $\begingroup$ @AlexMcKenzie The last-digits multiplication that you're talking about is exactly modular arithmetic (specifically, it's the multiplication table mod $n$). A cute example: look at the table of last digits for the base-7 multiplication table. Notice that every row has each non-zero number exactly once, and (by symmetry) so does every column? This isn't a coincidence! This will happen whenever your base is a prime; the numbers mod $p$ form what's called a group under multiplication. $\endgroup$ – Steven Stadnicki Apr 25 '15 at 17:14
  • $\begingroup$ @AlexMcKenzie In fact, let me flesh out my answer a little bit to explain what I mean by that first sentence... $\endgroup$ – Steven Stadnicki Apr 25 '15 at 17:22
  • 1
    $\begingroup$ Correct me if I'm wrong, but essentially this is a graph of multiple instances of $xy = C$ separated by a multiple of $n$. this is what forms the pattern in the corners. Then, since I'm sampling across a grid of finite pixels, a moire pattern forms. So if I had an infinitely large image, I would only see the $xy = C$ pattern, and not the artifacts. $\endgroup$ – Alex McKenzie Apr 25 '15 at 17:22
  • 5
    $\begingroup$ @AlexMcKenzie Also, congratulations on finding this! This sort of pattern-hunting is an excellent way of experimenting in mathematics and learning about all sorts of facets of its vast world. $\endgroup$ – Steven Stadnicki Apr 25 '15 at 17:38

You can model your graphics as computing $f_n(x,y)=n\left[\frac{xy}{n}\right]$, where here the square brackets are ad-hoc notation to mean taking the fractional part (or "reduce modulo 1"). This takes $z=xy$ and cuts it at a bunch of horizontal hyperbolae, collapsing the graph like a Fresnel lens. Then, what you are doing is sampling $f_n$ on integer points $\{(i,j)\in\mathbb{Z}^2:1\leq i,j\leq n\}$, but $f_n$ oscillates faster than your sample grid, leading to a Moire pattern.


These would be the powers in a discrete Fourier transform matrix: http://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.