Sometimes things happen in our surroundings that we ignore easily but for a real scientist, they are seeds to further investigations. A famous example as we all know is Newton’s apple. Here I want to trigger your curiosity by giving some simple examples: have you ever noticed that a big group of people can clap in sync without any prior training? How is that even possible?
Sometimes these observations can go to extreme forms that not only make a scientist question but also ordinary people. We all know fireflies flashing in nights but in some places on earth, they gather in flocks of thousands, and then they start flashing in sync! there is a short video on this here:
How is that possible? How a small firefly from one side of the forest knows when another firefly is flashing hundreds of meters away? This was a big mystery for almost a century for scientists until in 1992 a group of American scientists started to study the behavior. Well, the media started to make fun of them with titles: “Did you know your tax money goes to study fireflies in Borneo?” Nonetheless, the results of the study created a new science!
Let’s start very simple. Let's assume every firefly has an inner clock that tells her to flash when the clock is exactly on 12.
But instead of an all to all communication between all the fireflies, each firefly starts to move forward her clock when she sees another nearby firefly flashes. This helps her to be closer to the other firefly on the next flashing.
And that’s it! This simple procedure is enough to make the whole flock of fireflies flash together in sync. But this is just an oversimplification and we know that “The devil is in the detail.”
Let’s get more formal
There are a lot of details in this weird behavior that we call “self-organization”. It’s the property of some dynamical systems that we try to know more about.
Consider a population of N fireflies that we call them oscillators from now on. Each oscillator is exactly like a clock which means mathematically it has a phase (theta). The rate at which theta is changing is the frequency of the oscillator (how many times it rotates in one second?). In mathematical terms:
At first, the frequencies are random (they come from a random distribution) which means at first the fireflies light up with different frequencies.
But as we mentioned in the previous section, the frequencies will change based on the neighbors. In other words, every oscillator tries to get closer to the frequency of its neighbors. There are a lot of ways to formulate this behavior. The most famous one is the Kuramoto model. In this model the frequency of each oscillator changes at a rate that is proportional to the frequency distance between the oscillator and others. This distance is defined based on the sine of the difference between the phases. (take a pause and think why they chose sine function?). For now, assume each oscillator sees all other oscillators and not just the neighbors. So we have to consider the average of all other oscillators:
In which we have parameter K (the coupling) that shows how much oscillators get influenced by each other. The following figure shows a picture of oscillators. You can consider each oscillator as a firefly!
For small K, even for a lot of oscillators that start randomly, there would be no synchronization. But if K is big enough the synchronization will happen eventually. K_c is the critical value of K at which for values of K >K_c the sync will happen.
Even though the above model is working it is unrealistic. As for fireflies, the oscillators jus can see local oscillators. So, in a more realistic setting we just have local connections:
In which V(i) is the set of oscillators that are closest to i and sigma is the coupling parameter.
Finally, we need another definition to finish this part. To measure how much oscillators are close to each other we can calculate the mean of phases.
This “empirical mean” is a real number between 0 and 1. 0 means total randomness and no coherence and 1 means complete synchronization.
In the fig above, in (a), the phases are more scattered and they cancel each other out. But in (b) the phases are clustered in one place and show more coherence.
How fireflies arranged in space?
But maybe the most important question is that how fireflies arranged in space? By arranging we mean how they communicate with each other? If we model the communication as a network (or a graph). Then the first obvious thing to know is that this graph is not fully connected. The fireflies communicate much more locally. But again, with more studies, it turned out the communication network has more interesting features than a locally connected network.
Studies on complex networks revealed that networks in big scales behave like an organism and follow certain mathematical and statistical properties. One important property is that the probability at which two nodes are connected will increase if they have neighbors that are connected to each other. This property leads to local connections. The other property is that in these networks the shortest distance between every couple of nodes is very small. This feels counter-intuitive at first glance but makes more sense when you look at them as a big network with dense local clusters. The networks with the mentioned properties are called “small-world networks”. More specifically, in small-world networks with N nodes, the average distance between every two nodes (L) is:
It’s interesting to know that small-world networks are everywhere, they are not the exception but rule! Social networks, Protein-Protein interaction networks, the Internet, and even the human brain are small-world networks. In small-world networks, the number of steps required to go from a node to any other node is much smaller than you might think! The “6 degrees of separation” is famous for this!
The other important feature of these networks is being “scale-free”. “Scale-free” means the network looks the same at different scales! almost like a fractal. The reason behind “scale-free” property is the power law in degree distribution:
In the formula above the gamma is a number between 2 and 3. But the important point is that these networks are not artificial! In other words, all these nice features emerge in complex networks in nature by itself! they evolve to have these features, so the problem is how to simulate them in an artificial environment like a computer simulation?
But wait, why even we talk about the networks? What is the relationship to the sync in nature? The short answer is that the synchronization can’t happen so easily as we talked about it in the first section. It happens in the context of small-world networks! One reason is that in small-world networks the information flow speed is high due to local clusters. There have been so many studies to show the behavior of sync in different networks. For example, in lattices, “sync” can happen locally. The following video shows it on a cube:
But small-world networks are more successful to incorporate sync behavior in them compared to any other network.
Even though small-world networks are created in nature but finally the mathematician found some ways to simulate them in computer programs (no simulation or mathematical modeling to this day is a perfect simulator). Here we define three important artificial networks that to some extent follow the patterns in nature:
Erdős–Rényi model: This model is a simple graph in which each node connects to other nodes with probability p. The degree distribution in this network follows the poison distribution.
Barabási–Albert model: In this model, we first create a graph with m nodes and some random edges, and then we try to add more links by a probability corresponding to the number of connections of that node. Consequently, the nodes that have more links (friends) are more likely to have more links in the future! So the probability of connection is:
This process results in a network that follows the power law.
Watts–Strogatz model: This model looks for ways to create local clusters. To do this, it looks for something between lattices and random graphs. So it starts with a very organized graph like the one on the right picture and cut some links and connect them again randomly until it finds something that is not totally random and not ordered. This process results in a graph with local clusters but it doesn’t follow the power law.
As you realized so far, all these models lack one feature of natural networks. But they are a good approximation of what we have in nature.
We simulate the behaviors in MATLAB because of its simple syntax.
First, we create the Erdos-Renyi graph using adjacency matrix representation of matrices.
And for Barbasi-Albert graph:
And for that we use the auxiliary function:
And the Watts-Strogatz graph:
Now, it’s time to implement the most important part which is differential equations that need to be solved at the same time.
The only thing that remains is the main script to call them all:
As you can see from the code, first we create out model (all other models are commented out and you can also try them). Then we create the initial parameters which are parameters and step size. One important part of the code is to create the Omega, the initial frequencies, that we initialized with a normal distribution.
The main loop is on the time and every time we have to solve the differential equation of Kuramoto and then calculate the “localr” which is an equation and shows how much the angles (or phases) close to each other. Then, we keep all the angles in one vector (angles) and keep doing this for the next iteration. Finally, we plot the results and animate them in a for loop and the end.
The final output will look like this:
The sync behavior is not limited to fireflies but it is a universal law that can be observed everywhere! There are so many examples of it that we can’t cover them all but I just point out to a few more.
Another interesting example happens in crickets chirping at night. Suddenly you hear thousands of crickets all over the forest chirping together just like a big symphony.
“Sync” is not always a good thing, syncing behavior of neurons in the brain has a special name: epilepsy! In this mental problem, neurons start to fire together in millions! They become so synced and finally, resonance happens and it gets out of control.
On the other hand, some other forms of sync are crucial for our life. The most important one is the pacemaker cells that are responsible for the regular beats of our hearts. The sync also happens at a sub-atomic level with quantum interactions. To know more about this phenomenon I recommend the following book by Strogatz one of the leaders in this field:
All in all, “Sync” is everywhere and it’s a mathematical feature of our universe. “Sync” is the emergent dance of nature, and it seems like she likes to dance! A sync dancing known as “Sama” is one of the core features of mysticism and for this reason, it could have another level of meaning to some people too.