Christmas lights, trees and maths

Why do Christmas lights get tangled? And what’s the perfect way to decorate a Christmas tree? Find the answers here.


Christmas decorations, adapted from Flickr, CC BY-SA 2.0

Christmas is coming! For many it is the most wonderful time of the year, while for others it is simply an excuse to consume mince pies and mulled wine. This month we have been embracing the Christmas spirit with our competitions, don’t forget to take part! In the (very unlikely) event that you are already missing your maths lectures or research, today we bring you a special Christmas blog, in which we talk about some of the maths and science you can find during this holiday season. 

Christmas lights, why do they always get tangled?

Christmas lights. Public Domain

I have to admit that Christmas is my favourite season. I like everything about it: gathering with family and friends, amazing food and drinks, the cold weather. But one of the things that I dislike the most (and I think the majority of people will agree with me), is that moment when you have to decorate the Christmas tree. More specifically, unboxing the decorations, especially untangling the Christmas lights. A truly painful job to do that takes ages. The sad truth is that no matter how careful you are when you wrap them up, they will always find a way to get tangled. The same phenomenon happens with headphones. But why?

Examples of different knots. Matemateca, CC BY-SA 4.0

In 2007, physicists and mathematicians from the University of California and the University of Chicago published some amazing work to explain the spontaneous formation of knots. In their paper called Spontaneous knotting of an agitated string, they performed a series of experiments in which a string was shaken or tumbled inside a box, and they observed that knots are formed within seconds. Additionally, using mathematical knot theory they found that there is a high probability of formation of knots for cords that are longer than 2m.  The relevance of their paper is that they helped to explain how spontaneous or random motion leads to knotting and not the other way around. In order to clarify this, we will use one of the universal laws, a law that is considered to be one of the seventeen equations that changed the world: the second law of thermodynamics (if you want to read more about the laws of thermodynamics, click here!).

The second law is about entropy, a thermodynamic quantity that is used as a measure of the chaos of a system.  Entropy can also be seen as a way of measuring things that are likely or probable to happen in nature: it is a lot easier for things to get broken than it is for them to stay together. For instance, if you put ice cubes in liquid water, there are a lot more ways for the water molecules to arrange themselves than when they are in a solid state. In thermodynamics, we say that there is an increase in entropy as the ice melts, which is exactly what the second law of thermodynamics is about: high entropy objects are untidy, which makes them more likely to exist. On the other hand, low entropy objects are tidy and very unlikely to exist. Mathematically speaking, the entropy $S$ can be defined as:

$$S = k \, \ln \Omega,$$

where $k$ is the Boltzmann constant ($k=1.38064\times10^{-23} \text{m}^2\text{kg s}^{-2} \text{K}^{-1}$), and $\Omega$ is defined as the number of configurations that a system can have under determined thermodynamic conditions. For instance, in an ideal gas, the number of configurations $\Omega$ is the number of ways the atoms or molecules of the gas can be arranged at a fixed temperature and pressure.

The equation for the second law of thermodynamics in an isolated system is:

$$ \Delta S \geq 0,$$

which simply states that there will always be an increase of entropy in an isolated system.

Going back to the Christmas lights, there is only one possible configuration for the string of Christmas lights that keeps them from being tangled, which is when the cord is completely straight, ie $ \Omega_1=1$ and $S_1 \geq 0$ (see image below). But any single twist or bend of the cord will lead to the formation of knots, as there are a large amount of more ways for the lights to get tied up, and therefore the second law is satisfied, as $ \Omega_2 \gg 1$ and $S_2 \gg 0$. These equations are simply telling us that if Christmas lights are moved randomly then they get entangled and messy. Additionally, once a knot forms, it is extremely likely that more knots will form, and not the other way around.

(a) One simple configuration: untangled state

(b) Multiple configurations: multiple knots, entangled state

Lastly, the number of configurations (number of knots) of the Christmas lights is proportional to the length of the string, which means that the longer the cord, more tangled the lights will be, which also means more suffering at the moment of unpacking them and trying to untangle them. So next time you get desperate and stressed while untangling your lights or headphones, you now know who to blame: the second law of thermodynamics!

The mathematical equation for the perfectly decorated Christmas tree

A (perfectly?) decorated Christmas tree. Public Domain

After finally succeeding in untangling your Christmas lights, is time to decorate your house, but most importantly your Christmas tree. Although it may seem that this job is a lot of fun to do, decorating your tree might be really painful for many of us: you will probably run out of tinsel and baubles, or the lights are too short or there is a missing bulb. If you didn’t lose your mind while trying to untangle your lights, you will definitely lose it at this stage. The only solution is to set your tree on fire.

Fortunately, mathematicians from the University of Sheffield offer us a more environmentally-friendly solution to this problem, as they have developed a mathematical equation to perfectly decorate your Christmas tree. The equation, which they call the Treegonometry formula, calculates, given the height of your tree, the number of ornaments, length of tinsel and lights and height of the angel or star required to get an aesthetically balanced Christmas tree. Their equation, derived in 2015, adopts the following form:

$$H: \text{height of Christmas tree in cm}$$

$$\text{Length of tinsel in cm}= \frac{13 \,\pi}{8} H,$$

$$\text{Length of lights in cm}= \pi \, H,$$

$$\text{Height of star in cm}= \frac{H}{10},$$

$$\text{Number of baubles}=\frac{\sqrt{17}}{20} \, H.$$

Problem solved! But if you are too lazy to do these simple calculations, visit their website and simply put the height of your tree into their calculator.

Virtual Christmas tree

If you do not want to waste time, and you prefer to avoid stress caused by untangling lights and decorating trees, we have a nice alternative for you: a virtual Christmas tree. I was browsing the web and found some code that you can run in your preferred maths software (Mathematica, MATLAB, etc) to give you a fantastic and colourful Christmas tree.

For instance, I ran the code provided here in Mathematica, and I got the following:

Amazing, isn’t it? If you prefer to use MATLAB, visit this webpage and run their code. If you have found any others, or even better you have constructed your own code, we would love to see it!

If you want even more mathematical Christmas trivia to share over Christmas dinner, check out our previous posts The Science behind Santa Claus and Snowflake, the symbol of winter. Merry Christmas!

Hugo is a chemical engineer doing a PhD in Mathematics at University College London. He is currently working on non-Newtonian fluid dynamics. He is also interested in transport phenomena and rheology (the science of deformation).

More from Chalkdust