I have been occasionally obsessed with this video for years and I finally sat down to deconstruct it. The video shows a row of 15 pendulums, with each pendulum being slightly shorter than the last. All of the pendulums are started swinging at once and they follow a kind of snaking pattern that devolves into chaos. However, they occasionally line up into two or three groups that swing together before falling out of phase again. After 60 seconds they all line up in one row and the pattern repeats.

Have a watch:

How does it work?🔗

So how does this demo work? How can a set of independent pendulums alternate between complete chaos and perfectly aligned rows? There's a hint on this page:

The period of one complete cycle of the dance is 60 seconds. The length of the longest pendulum has been adjusted so that it executes 51 oscillations in this 60 second period. The length of each successive shorter pendulum is carefully adjusted so that it executes one additional oscillation in this period. Thus, the 15th pendulum (shortest) undergoes 65 oscillations. When all 15 pendulums are started together, they quickly fall out of sync—their relative phases continuously change because of their different periods of oscillation. However, after 60 seconds they will all have executed an integral number of oscillations and be back in sync again at that instant, ready to repeat the dance.

This quote gives us a decent picture of how to build one of these for ourselves if we wanted to but it misses why this system works in the first place. It does tell us that the arrangement of the frequencies is important so let's start there.

Let's start by writing out an equation for where each pendulum is at a given point in time. The standard way to describe the motion of a pendulum is to start with all the forces acting on it, then use the "small angle approximation" and end up with this equation (which I've simplified a bit)1

p(t)=cos(2πft) p(t) = \cos(2\pi f t)

Where ff is the frequency of the pendulum in cycles per second and tt is the time since the pendulums started swinging in seconds.

An important property of cos\cos is its periodicity. That is, it follows a repeating cycle. We will be using this property a lot, so I will go ahead and state it here:

cos(x)=cos(x+2π)=cos(x+c(2π)) \cos(x) = \cos(x + 2\pi) = \cos(x + c(2\pi))

where cc is any integer.

Why does the cycle repeat after 60 seconds?🔗

From the quoted description above, each pendulum has a frequency one cycle per minute higher than the previous ranging from 51 to 65 cycles per minute. The equation for the iith pendulum is then

pi(t)=cos(2πt50+i60) p_i(t) = \cos \left(2 \pi t \frac{50 + i}{60}\right)

The description states that the cycle repeats after 60 seconds, and we can verify that by plugging in 60 for tt.

pi(60)=cos(2π60(50+i)60)=cos(2π(50+i))=cos(0)=1 p_i(60) = \cos \left(2 \pi \frac{60(50+i)}{60} \right) = \cos(2 \pi(50+i)) = \cos(0)=1

Note that the final term is independent of ii, so all the pendulums must have the same position at the peak of their swing (also meaning their velocity is 0) at 60 seconds after they started swinging. Furthermore since a pendulum's state is fully determined by its position and velocity, the pendulums have all returned to their initial state at the same time and the system must repeat its behavior. You can also verify that this holds for any multiple of 60 seconds, meaning that this whole system must have a period of 60 seconds.

What about the wavy rows of pendulums?🔗

Let's focus on the clearest pattern which is when the pendulums line up in two rows made up of every other pendulum. It seems to happen at roughly halfway through the cycle and we can check exactly when it happens by figuring out when a pendulum lines up with another two steps further down the line. We can accomplish that by setting pi(t)=pi+2(t)p_i(t) = p_{i+2}(t) and solving for tt.

pi(t)=pi+2(t)cos(2πt50+i60)=cos(2πt50+i+260)cos(2πt50+i60)=cos(2πt50+i60+2πt30) \begin{aligned} p_i(t) &= p_{i+2}(t)\\ \cos\left(2 \pi t\frac{50+i}{60}\right)&=\cos\left(2\pi t \frac{50+i+2}{60}\right)\\ \cos\left(2 \pi t\frac{50+i}{60}\right)&=\cos\left(2\pi t \frac{50+i}{60} +\frac{2\pi t}{30}\right) \end{aligned}

This holds true when 2πt30\frac{2 \pi t}{30} is a multiple of 2π2 \pi or equivalently when t30\frac{t}{30} is an integer. That happens when tt is a multiple of 30 meaning our solutions are t=0,30,60,90t=0, 30, 60, 90 and so on. We already knew about the multiples of 60 -- that's when all of the pendulums line up in one row -- so the two rows of pendulums must show up at exactly 30 seconds into the cycle. More precisely, that is exact moment of time when they should be in perfect straight rows. The pattern will be visible for a range of time before and after that point, and due to random variations in starting conditions the rows won't be perfect.

To see why there are two different rows instead of a single row at 30 seconds, let's plug in some numbers for specific pendulums.

p1(30)=cos(2π305160)=cos(2π(25.5))=cos(π)=1p2(30)=cos(2π305260)=cos(2π(26))=cos(0)=1p3(30)=cos(2π305360)=cos(2π(26.5))=cos(π)=1p4(30)=cos(2π305460)=cos(2π(27)=cos(0)=1... \begin{aligned} p_1(30) &= \cos\left(2 \pi \frac{30 * 51}{60}\right) = \cos(2 \pi (25.5))=\cos(\pi) = -1\\ p_2(30) &= \cos\left(2 \pi \frac{30 * 52}{60}\right) = \cos(2 \pi (26)) = \cos(0) = 1\\ p_3(30) &= \cos\left(2 \pi \frac{30 * 53}{60}\right) = \cos(2 \pi (26.5))=\cos(\pi) = -1\\ p_4(30) &= \cos\left(2 \pi \frac{30 * 54}{60}\right) = \cos(2 \pi (27)=\cos(0) =1\\ ... \end{aligned}

So the pendulums with odd indices all line up on one side and all the pendulums with even indices line up on the other.

What about the other patterns? You can see three rows fairly clearly and even four somewhat. In fact, there is a broader pattern here the explains all of these patterns. Let's look at when two pendulums with an arbitrary gap of kk pendulums line up.

pi(t)=pi+k(t)cos(2πt50+i60)=cos(2πt50+i+k60)cos(2πt50+i60)=cos(2πt50+i60+2πtk60) \begin{aligned} p_i(t)&=p_{i+k}(t)\\ \cos\left(2 \pi t \frac{50+i}{60}\right)&=\cos\left(2\pi t \frac{50+i+k}{60}\right)\\ \cos\left(2 \pi t \frac{50+i}{60}\right)&=\cos\left(2\pi t \frac{50+i}{60}+2\pi t \frac{k}{60}\right)\\ \end{aligned}

So two pendulums which are kk pendulums apart line up when tk60\frac{tk}{60} is an integer. Equivalently, that is when tt is a multiple of 60k\frac{60}{k}. For example, the first and fourth pendulum (a gap of three) will line up at t=0,20,40,60,80t=0, 20, 40, 60, 80 and so on every 20 seconds. Similarly, the fourth and seventh pendulums line up at the same times, as well as the second and fifth. If you were to plug in t=20t=20 to each of the equations as we did above, you would see three different groups of pendulums made up of every third pendulum lined up at exactly 20 seconds. In general, when tt is a multiple of 60k\frac{60}{k} you will see kk rows of pendulums made up of every kkth pendulum. However, since there are only 15 pendulums in the video k=5k=5 only gives us three pendulums in a group and anything above k=7k=7 puts only one pendulum in most of the groups. Because of that it is fairly difficult to see anything more than four groups of pendulums lining up at once.

Why do we sometimes see fewer rows than expected?🔗

If we keep investigating, there is something interesting that happens when you plug in k=4k=4. If you look at the times where you should see four rows of pendulums you get t=0,15,30,45,60t=0,15,30,45,60 and so on. So we should see four rows at t=30t=30 but we already know that there are only two rows at that point. Something similar happens at t=60t=60 for all of these values where we might expect there to be kk rows, but we already know there is only one. What's happening here?

Let's look at the statement we proved above a bit more carefully. We showed that a pendulum with index ii will line up with the pendulum with index i+ki+k whenever tt is a multiple of 60k\frac{60}{k}. When tt is 30, it is a multiple of 604=15\frac{60}{4} = 15 so pendulum ii lines up with pendulum i+4i+4. However, 30 is also a multiple of 602=30\frac{60}{2} = 30 (i.e. 1301\cdot 30) so pendulum ii lines up with pendulum i+2i+2. Both of these statements are true simultaneously, in particular because the second statement implies the first. 2 So rather than having two distinct rows at (i,i+4,i+8,...)(i, i+4, i+8, ...) and at (i+2,i+6,i+10,...)(i+2, i+6, i+10, ...) as you would have at t=15t=15 or 4545, the two rows actually appear merged together as one at t=30t=30.

In general this will happen whenever we have a time 60ck60 \cdot \frac{c}{k} where cc is an integer and cc and kk share a common divisor. For example, with k=6k=6 you will see six rows at t=6016=10t=60\cdot\frac{1}{6}=10, then three at t=6026=6013=20t=60\cdot\frac{2}{6}=60\cdot\frac{1}{3}=20, then two at t=6036=6012=30t=60\cdot\frac{3}{6}=60\cdot\frac{1}{2}=30. In summary, for any rational multiple of the period, 60pq60 \cdot \frac{p}{q}, where pp and qq are integers with no common factors (i.e. the fraction has been reduced to its lowest terms) you will see qq distinct rows of pendulums. However, you are limited by the number of pendulums in the system since any kk above 15 will have rows with zero pendulums.

An interesting consequence of this is that if kk is a prime number you will see kk rows of pendulums at k1k-1 distinct times. 3 Also, if you look at where each of the rows goes at each solution for tt for a particular kk you'll end up with something that looks like the subgroups of the cyclic group of order kk.4

What can we change?🔗

So is there something special about those frequencies that makes this work? Intuitively it seems like you should be able to slow down the video or equivalently slow down all of the pendulums by making them longer and still see the same system. In fact the frequencies and number of pendulums does not matter as long as there is a fixed frequency gap between them. In this case the gap is one swing per 60 seconds but it could be anything you like, and there could be as many pendulums as you like.

Additionally, the only property we used to prove all the statements above was periodicity. Because of that we can construct a system that has similar behavior using any periodic function. One I particularly like is the movement of clock hands around a clock. 5 With this visualization it is much easier to see the patterns for higher values of kk. You can also turn the number of hands up to something like 120 for a particularly stunning experience.

Full screen.

How far can we take it?🔗

This system has a limit as it stands. In principle you should be able to see kk groups at some time for any given kk. However with finitely many oscillators (e.g. pendulums or clock hands) you cannot see more groups than you have oscillators. What I want is a system where for any rational number pq\frac{p}{q} in lowest terms you will see qq evenly spaced groups of oscillators at t=pqt=\frac{p}{q}.

The closest thing I've seen before is Thomae's function which is commonly used as an example of a function with bizarre continuity properties. However, I want something that operates over both time and space so that we can see where the oscillators are at any given point in time. Thomae's function is one dimensional and can't quite accomplish what I want, so we'll have to extend it a bit.

f(x)={1qif x=pq,pZ,qN,gcd(p,q)=10if x is irrational f(x) = \begin{cases} \frac{1}{q} & \text{if } x = \frac{p}{q}, p \in \mathbb{Z}, q \in \mathbb{N}, gcd(p, q) = 1 \\ 0 & \text{if } x \text{ is irrational} \\ \end{cases}
Thomae's function
Thomae's function

The best I can come up with is the following:

f:R×[0,1)Q f:\mathbb{R}\times [0,1) \rightarrow \mathbb{Q} f(t,x)={1,t=0 and x=01q,if x=pq, with pZ and qN coprime, and t=rq, with rZ and r,q coprime0,otherwise (i.e. x,t irrational or don’t share a common denominator in reduced form) f(t, x) = \begin{cases} 1, &t=0 \text{ and } x = 0\\ \frac{1}{q},& \text{if } x=\frac{p}{q}\text{, with } p \in \mathbb{Z} \text{ and } q \in \mathbb{N} \text{ coprime, and } t=\frac{r}{q}, \text{ with } r\in\mathbb{Z} \text{ and } r,q \text{ coprime} \\ 0,& \text{otherwise (i.e. } x,t \text{ irrational or don't share a common denominator in reduced form)} \end{cases}

Essentially this says that if tt and xx share a common denominator in reduced form (with 0 being interpreted as 01\frac{0}{1}), then the value is one over that denominator. Otherwise the value is zero. I'm not particularly sure how to make a proper visualization of this since all the patterns become actually instantaneous and the function is technically zero for essentially all values of tt. Therefore I'm going to leave this as an open challenge.

Challenges🔗

Send me whatever you come up with for these open-ended challenges.

  1. Where else can you find this kind of system?
  2. Implement/build a visualization of this kind of system. Try using another kind of periodic function (e.g. turn signals, planetary systems, something with audio), be creative!
  3. Implement the above definition for an infinite analog in an appealing way.
  4. Formulate some alternative definition for an infinite analog to this system.
  5. Send me an interesting challenge to put here.

Footnotes🔗

1

https://en.wikipedia.org/wiki/Pendulum_(mathematics) for the standard derivation, if you're interested in a more thorough look this video by 3Blue1Brown is fantastic

2

pi(30)=pi+2(30)p_i(30) = p_{i+2}(30) implies pi+2(30)=pi+4(30)p_{i+2}(30) = p_{i+4}(30) and by the transitive property of equality pi(30)=pi+4(30)p_i(30) = p_{i+4}(30)

3

Not kk since it still must line up in one row at multiples of 60

4

Actually, the multiplication table for Z/Zk\mathbb{Z}/\mathbb{Z}_k (integers mod kk) is a much better description of what I meant. Thanks, Stephen.

5

You can also think of this as the complex exponential if you want to