post

The pipe singularity

Uproar and bewilderment had followed the plenary congress that had been held in the vast expanses of the imperial palace of Atzlan, the Aztec capital. Remotep, head of the royal laboratory, had made a great announcement. Following years of observations, studies and experiments, the renowned scientist had been able to forge a complete picture of the fundamental principles of life: this knowledge had already brought enormous advances to humanity but would soon completely revolutionise human existence.
Continue reading

post

Superegg

If there’s a perfect time to write about eggy shapes, it must be Easter. This article reads best while munching on your chocolate egg hunt loot.

Let me take you to centre of Stockholm—back in 1959. The capital of Sweden was being rebuilt after World War II. As part of this program, two big arteries had been built and they intersected in the heart of the city: Sergels torg (Sergel’s Square). This place appeared to be a big problem for city planners, as its shape wasn’t really a square, but a rectangle.

The idea was to plan a roundabout around it. But what shape should this roundabout have? A circle?

circle_rectangle

Such a waste of space! Ellipse?

Too narrow for the traffic in the red parts.

Desperate times call for desperate measures, ie for mathematicians. More precisely, the team of architects asked for help from Piet Hein, a Danish mathematician, inventor, designer, author, and poet (what else?!). And he invented a superellipse.

To simplify the task, let’s start with a circle. Just a standard $x^2+y^2=1$—nothing fancy.

circle1

Have you ever wondered what happens if we enlarge the exponents in this familiar equation? So what does, for example, $x^6+y^6=1$ look like?

circle2

Is it a circle or a square? Or maybe a squircle? The higher the exponent, the closer to a square we get: $x^{100}+y^{100}=1$ is almost indistinguishable from a square.

circle3

Now let’s complicate things, just a little bit, and look at a more general shape: an ellipse. For example, $\left(\frac{x}{3}\right)^2+\left(\frac{y}{2}\right)^2=1$ looks like this

ellipse1

Again, as we enlarge the exponents, we get closer and closer to a rectangle. So here’s $\left(\frac{x}{3}\right)^{10}+\left(\frac{y}{2}\right)^{10}=1$

ellipse10

and $\left(\frac{x}{3}\right)^{100}+\left(\frac{y}{2}\right)^{100}=1$

ellipse100

Almost a rectangle, right? These interesting shapes are called superellipses.

Remember that our original problem was to build a roundabout rectangular enough to fill most of the available space and circular enough to allow for smooth traffic flow. Hein found out that the perfect shape was an ellipse with exponent equal 2.5 (precisely, the Sergels torg roundabout can be described by $\left(\frac{x}{6}\right)^{2.5}+\left(\frac{y}{5}\right)^{2.5}=1$).

Superellipses quickly became popular among architects all over the world. For example, the famous Mexican Azteca Olympic Stadium has such a shape.

Other applications include:

  • A possible shape of the table for negotiators after the Vietnam War, as a compromise between a circular one (“everyone’s equal”) and a rectangular one (“two sides on the conflict”).  Unfortunately, this amazing idea was rejected.
  • The Tobler hyperelliptical projection (a method for drawing maps) uses arcs of superellipses as meridians.
  • In mobile operating systems, iOS app icons have superellipse curves.

Don’t get impatient, I haven’t forgotten about Easter! Take your favourite superllipse, rotate it along its longest axis and you’ll get a superegg! Why is it so super? Well, it can stand upright on a flat surface or on top of another superegg. This is a proper solution to the egg of Columbus problem!

Superegg

Brass superegg by Piet Hein. Image: Malene, CC BY-SA 3.0

Happy Easter!

post

Is it better to run or walk in the rain?

One of the many things affecting us living in the UK is the rain! Especially when we are caught out in it without an umbrella (or when we’re too lazy to dig it out of our bag). Intuitively it seems like a good idea to run, or at least walk faster so we spend less time in the rain, however this means that the rain hits our front at a faster rate. So what’s the best thing to do in order to minimise how wet you get? This problem has actually been discussed quite a bit in the past few decades, from mathematical journals to tv shows like Mythbusters (they actually did two episodes on this, the second being a correction!).

Let’s start with the simplest model, imagine the rain coming straight down at a constant rate. In the figure to the left, you are represented as the grey rectangle (since the rain has made you sad). Suppose also that the raindrops fall uniformly and such that you cannot walk ‘into’ it, i.e. the rain is only hitting your head. In this case, regardless of the rate at which the rain is falling, your best option is to move as fast as you can to minimise your time spent in the rain.

 

$k$ and $c$ are just positive constants here to show that the lines in the diagram are proportional to the actual vectors

Well, what if the rain is coming down towards you at an angle due to the wind? For this we’ll want to introduce some actual maths. Again, we will assume the rain is falling uniformly with a constant velocity $\textbf{v}_r$. An important concept in this problem is the rain region. This region contains the initial positions of all raindrops that will hit you at some time. Suppose you’re moving with speed $s$, so your velocity in 2D is $\textbf{v}_u=(s,0)$, scaled such that you spend the time $1/s$ in the rain. Let’s put a point $P$ on you, and take a point $Q$ from the rain region, representing a rain drop that will hit you at time $t$. Then, this rain drop will hit you at position $Q+\textbf{v}_r t$. Your original point $P$ can be written as $P=Q+\textbf{v}_r t-\textbf{v}_u t$. Thus for every (exposed) point on you, $P$, the points $P+ (\textbf{v}_u -\textbf{v}_r)t$ are in the rain region for $t \in [0,1/s]$. The rain region is entirely made up of these lines, each with length $||\textbf{v}_u -\textbf{v}_r||/s$. It should be clear then if the rain is coming down at an angle, hitting your front, you should run as fast as you can to minimise the length of the rain region (the ‘width’ of the rain region will be fixed, proportional to your height).

What if the rain is coming from behind you? Here things get a little more complicated. The components of the rain’s velocity are $\textbf{v}_r=(v_r^1,v_r^2)$ where $v_r^1>0$ since the rain is falling in the forwards direction. A few things distinct things can happen here (with our assumption of the rain falling uniformly, at the same velocity). Recalled you move with speed $s$. If $s>v_r^1$ you will overtake the rain falling from behind you and only your top and front gets wet. If $s=v_r^1$ you are moving with the rain and only the top of you gets wet. Finally, if $s<v_r^1$ the rain hits your back and top, but you do not walk into any rain so your front remains dry. Let $A_{fb}$ be the area of your front or back exposed to the rain, and $A_{t}$ is the area of the top of your head. In our 2D case, these would just be the height and width of your ‘rectangle’, respectively. The amount of rain hitting these parts are then proportional to $R_{fb}=|v_r^1-s|A_{fb}$ and $R_{t}=|v_r^2|A_{t}$ (again, respectively). Recalling that the time spent in the rain is $1/s$, the total wetness function, $R$, is proportional to:
\begin{align} R_1(s)=\frac{1}{s}[ (v_r^1 – s) A_{fb} + |v_r^2| A_{t} ]; \quad \text{if } s\leq v_r^1 \nonumber \\
R_2(s)=\frac{1}{s}[ (s-v_r^1) A_{fb} + |v_r^2| A_{t}]; \quad \text{if }  s>v_r^1
\end{align}
where the multiplier for the proportion is just the density of the rain. Note that this function can be applied to the previous case too where the rain is falling backwards, into you ($v_r^1<0$). We find that we always have $R=R_2$ and the way this is minimised is to increase $s$ as much as possible.

For the case of the rain falling forwards we have $v_r^1>0$. Let $C=-v_r^1 A_{fb} + |v_r^2| A_{t}$ and notice that $R$ is continuous, $R_1$ is a decreasing function of $s$, whilst the behaviour of $R_2$ depends on the sign of $C$.

  • If $C>0$, $R_2$ is also a decreasing function of $s$ and $R$ will be minimised when $s$ is increased to its maximum.
  • If $C=0$, then $R_2$ is a constant and we can minimise $R$ by taking any $s\geq v_r^1$.
  • If $C<0$, $R_2$ is an increasing function of $s$, so we can only minimise $R$ by taking $s=v_r^1$, i.e. you run at exactly the horizontal speed of the rain.

$C$ depends on your size and the velocity of the rain. If the rain is only slightly falling forwards, then your best option will still be running as fast as you can! However, if the rain is falling forwards by a decent amount (such that $C<0$), then you’re better off running at exactly the horizontal speed of the rain. This also means the rain will only be hitting your head (theoretically)!

There are many more complicated models for this, taking into account things like different shapes (other than rectangles) or gusts of wind which affect the final conclusions.  Instead, we’ll just end on a limerick by Matthew Wright (unfortunately, not the previous member of Chalkdust)!

When caught in the rain without mac,
walk as fast as the wind at your back.
But when the wind’s in your face,
the optimal pace
is fast as your legs will make track.

In many of these related articles, you’ll find this limerick as a longer poem, adjusted to include the new results! For example, here is one by Dan Kalman and Bruce Torrence (or as they called themselves, Dank Hailman and Bruce Torrents):

When you find yourself caught in the rain,
while walking exposed on a plane,
for greatest protection
move in the direction
revealed by a fair weather vane.
Moving swift as the wind we’ll concede,
for a box shape is just the right speed.
But a soul who’s more rounded
will end up less drownded
if the wind’s pace he aims to exceed.

post

Why self-service machines give such awful change

You’ve got this down. You’ve bagged your groceries, swiped your Nectar card, and you’ve paid with a fiver. You’re due 55p change. Surely you’ll get a 50p and 5p coin, right? Nice and light in your pocket.

Wrong!

Self-checkout fans will know that you really get 20p, 20p, 5p, 5p, 5p.

Why?!

Last week, we advocated a new £1.23 coin in place of the new pound coin in order to reduce the number of coins you get in change. The answer to this self-service riddle is related.

Why do self-service checkouts give so much change?

Although supermarket self-checkouts accept all circulating coins, customers normally find that they only give out six possible coins as change. Normally these are

1p — 2p — 5p — 20p — £1 — £2.

They don’t give out 10p or 50p coins.

This is because self-checkout machines don’t reuse coins they are given. Instead, all the coins you put in are collected into a bucket [the brand that Sainsbury’s use call it a recycling acceptor: pdf]. The machines have separate tubes for coins as change, which are filled by staff with coins which have been checked by the bank as genuine.

The mechanisms for these tubes are expensive and prone to jamming. Combine this with the fact that many machines are based on US designs, where there are far fewer denominations of coin:

1¢ — 5¢ — 10¢ — 25¢ — $1,

you end up with machines with fewer coin tubes than types of coin.

This means that 99p in change (for example) requires nine coins with the current choice of coins to fill the machine with. But there’s a better choice of six coins. Suppose a machine has only n coin tubes to give out change. Which coins should it pick?

Coin tubes Coins Number expected
2 1p, 20p 21.5
3 1p, 20p, 50p 10.9
4 1p, 5p, 20p, £1 7.5
5 1p, 5p, 20p, 50p, £2 6.2
6 (self-checkout) 1p, 2p, 5p, 20p, £1, £2 (current) 5.9
1p, 2p, 5p, 20p, 50p, £2 (improvement) 5.4
7 1p, 2p, 5p, 10p, 20p, 50p, £2 or
1p, 2p, 5p, 20p, 50p, £1, £2
5.0

The message here is that £1 and 10p coins are less efficient than any other coin. The £1 coin, for example, is made up of only two 50ps, and it’s only half of £2.

So the self-checkout machines almost have it right: but if we’re going to use self-checkout machines with a small number of slots to give out change, we should swap the £1 coin tube for the 50p coin tube: then 99p is only six coins, instead of nine.

There is a good reason to keep £1 coins though: if you run out of £5 notes—a very common occurrence given that cash machines only give out £10 and £20 notes—you want to keep back your £2 coins for that. Maybe they have it right after all.

Speaking of Americans…

Are quarters better than 20-cent coins?

20-cent and 25-cent coins

Euro 20c vs Canadian 25¢. Fight!

Nearly all currencies have coin denominations starting with 1s and 5s. The differences can be found in between.

20-cent coins are favoured by most modern currencies (UK, Euro, most Commonwealth), whereas some older ones favour the 25-cent coin (US/Canada, Denmark, Thailand, pre-Euro Netherlands).

Is one more efficient than the other?

Coins Number expected Weight expected
1p, 2p, 5p, 10p, 20p, 50p, £1, £2 4.61 32.8g
1p, 2p, 5p, 10p, 25p, 50p, £1, £2 4.61 33.6g

Answer: they are equally efficient! Although, if you made a 25p coin weigh the same as a 20p coin, the expected weight is a little higher. (Fun fact: the UK used to have a 25p coin… but it was the same size/weight as the £5 coin.)

Programming this yourself

As with the £1.23 post, I am doing this all with a bit of Python code I found on StackExchange:

def get_min_coins(coins, target_amount):
    n = len(coins)
    min_coins = [0] + [sys.maxint] * target_amount
    for i in range(1, n + 1):
        for j in range(coins[i - 1], target_amount + 1):
            min_coins[j] = min(min_coins[j - coins[i - 1]] + 1, min_coins[j])
    return min_coins

This is nice code because it avoids the lazy approach (‘greedy algorithm’) of trying the highest coin first and then dealing with the remainder. Such a lazy approach is quick but fails if you have coins of 1p, 3p, 4p and want to make 6p. The lazy approach would give you 4p, 1p, 1p; but of course the best option is 3p, 3p.

Have a play with the code yourself. Do share below if you find anything interesting.

Bonus: How does the new £1 coin square off against the old one?

post

Is it possible to reach absolute zero?

German chemist Walter H Nerst [public domain]

The third law of thermodynamics (sometimes referred to as the heat theorem or unattainability principle) was postulated in 1912 by the German chemist Walther H Nernst and states that it is impossible to reach, by any procedure, the coldest temperature possible: absolute zero (0K, or −273.15C or −459.67F, depending on your preferred choice of units). However, this statement was a matter of some controversy, as there was no real proof of it. Although Nernst spent many years defending his version, many scientists refused to accept it, including such heavyweights as Max Planck and Albert Einstein. Both then started introducing their own versions. Einstein, for example, believed that the third law of thermodynamics must rely on the principles of quantum mechanics.

More than one hundred years went by and physicists and chemists from around the world were still debating the theorem, with some remaining unconvinced of its validity, given the lack of a proof.

However, a recently published paper in Nature Communications aims to clarify this debate. Researchers from the Department of Physics and Astronomy at University College London (UCL) have proven mathematically that it is impossible to reach absolute zero: we went to chat with one of them, Lluis Masanes.

Continue reading

post

Forget a new £1 coin, we need a £1.23 coin

Tomorrow, the Royal Mint—producer of British coins—is introducing a new, thinner, dodecagonal £1 coin. But they’re missing a trick. To cut the amount of change in our pockets, we don’t need a lighter £1 coin: we should replace it with a £1.23 coin.

New one pound coin

Coming soon to your pocket… the new pound coin. (Royal Mint)

The question you need to ask is: When you pay for something in a shop with a banknote, how many coins do you expect to get back in change? How much heavier will they make your purse?

The answers are different for different countries, so we’ve worked it out for your country as well!

How many coins do you expect to receive in change?

The smallest banknote in the UK is the meaty see-through £5 note. So if you pay with a note, you would hope to receive somewhere between 1p and £4.99 in coin change back. Supposing an even distribution of prices and that cashiers always give you the most efficient change (next week’s blog: when self-service machines don’t give efficent change), on average, then, how many coins do you expect to receive?

We’ve done the calculation for a few countries, for change amounts up to the smallest banknote.
You can find the code we’ve used at the bottom of the page.
Average number of coins expected as change in each country
Some variants on the UK system are highlighted in pink. Switching the £1 coin for a £1.23 coin reduces the coin expectancy by about half a coin, from 4.61 to 4.07: the best-performing option.

Some other observations:

  • Some countries do really well (India) because banknotes are used almost exclusively.
  • Low-scoring countries have abolished their smallest denominations (pennies etc.)
  • The US only has 4 common coins, yet averages the same number of coins as the UK with 8.
  • The pre-decimal UK system (pounds, shillings and pence) performs almost as efficiently as the current UK system.
  • The Harry Potter system (29 knuts in a sickle, 17 sickles in a galleon) is ridiculous.

And what about the weight of these expected coins in our pockets?

Average weight of coins expected as change in each country
Observations:

  • The UK has, on average, the heaviest coins out of the top 20 circulating world currencies. Removing 1p and 2p would reduce the weight by 20%.
  • Despite expecting the same number of coins in the UK and US, the weight of US coins is about half that of the UK.
  • Australian coins are heavy because their sizes are the same as pre-decimal UK ones.

If we could add just one coin, what would it be?

Suppose we were to keep all our coins, but could add one more. Which denomination would reduce the average number of coins you receive in change the most?
Average number of coins expected as change  if you add a new coin of a certain value
Adding a £1.33 or £1.37 coin would reduce the average number of coins from 4.61 to 3.93.

If you could choose any coins, what would they be?

So suppose we start over. A whole new set of coins up to £5. Designed to be the most efficient in terms of change. For a set number of coins, what would they be?

Number Coins Number expected
2 1p, 22p or 1p, 23p 21.3
3 1p, 14p, 61p 9.98
4 1p, 7p, 57p, 80p 6.82
5 1p, 6p, 20p, 85p, £1.21 5.45

Programming this yourself

I do this all with a bit of Python code I found on StackExchange:

def get_min_coins(coins, target_amount):
    n = len(coins)
    min_coins = [0] + [sys.maxint] * target_amount
    for i in range(1, n + 1):
        for j in range(coins[i - 1], target_amount + 1):
            min_coins[j] = min(min_coins[j - coins[i - 1]] + 1, min_coins[j])
    return min_coins

This is nice code because it avoids the lazy approach (‘greedy algorithm’) of trying the highest coin first and then dealing with the remainder. Such a lazy approach is quick but fails if you have coins of 1p, 3p, 4p and want to make 6p. The lazy approach would give you 4p, 1p, 1p; but of course the best option is 3p, 3p.

Questions to investigate

Next week we’ll use this code to answer the age-old question of

  • Why do supermarket self-checkout machines give such terrible change?

Plus, we’ll ask are quarters are better than 20-cent pieces?

Have a play with the code yourself. Comments are open below when you find something interesting.

Bonus: old £1 coin v new £1 coin

post

Cutting my birthday cake

Guess what? Today’s my birthday. I’ve invited my friends, I’ve got the cake, and I’ve blown out the candles. There’s only one thing left to do: cut the birthday cake. As I pick up the knife, ready to cut the cake for my hungry guests and me, a question suddenly pops into my head: what is the maximum number of pieces I can get by cutting my cake $c$ times?

Well, first things first, there’s loads of ways you could cut your cake. So our first ingredient for the answer to this question will be a handful of assumptions. In this blog post, I’m going to chop up a square cake with a normal knife. All cuts will be perfectly straight, and will go across the entire cake (so we won’t be starting from its centre). Also, the pieces you get after cutting the cake do not have to be the same size! And finally, we’ll pretend our cake is a two-dimensional object—a humble square.

Let’s suppose that $p_c$ is the maximum number of pieces you can obtain by cutting your cake in $c$ slices, and see what happens for different choices of $c$.

Start with the easiest case where $c=0$. In this case, you haven’t cut your cake yet, so of course you still have the whole cake. This is a single piece in its own right, therefore zero cuts give you one piece only ($p_0=1$).

Next, make a long, straight cut across your cake (this is $c=1$). I guarantee you will cut your cake into two, ie $p_1=2$.

Let's make one big cut down the middle

Let’s make one big cut down the middle

Now we’ll cut the cake a second time ($c=2$). Your best bet is to make sure the second cut passes through both pieces, so you end up with four pieces. In other words, $p_2=4$.

Now let's make a second cut

Now let’s make a second cut

Time for a third cut. It turns out you can obtain a maximum of seven pieces ($p_3=7$).

And a third cut...

And a third cut…

Now, if we make one more cut (ie $c=4$), how many slices can we make? The answer is in fact eleven. Don’t believe me? Have a look at the picture below and count up the bits for yourself

A fourth cut gives us 11 pieces... count them!

A fourth cut gives us 11 pieces… count them!

Let’s summarise what we know so far. As shown in the graph below, our sequence (starting from $c=0$) is $p_c=1,2,4,7,11,$ etc. This sequence does indeed have a formula, but before I reveal it, see if you can spot the pattern. Give up?

The number of pieces follows a familiar sequence...

The number of pieces follows a familiar sequence…

The best way to see the pattern is to take one away from each term in our sequence, we are left with $0,1,3,6,10,$ and so on. That’s right: these are the triangle numbers! Remember, since we started our sequence from $c=0$, we also have the zeroth triangular number, which is nothing but zero.

Recall that the $c$th term for the triangle numbers is $c(c+1)/2$, so we can write out a formula for the number of pieces we get from $c$ cuts. It’s…\[\frac{c(c+1)}{2}+1.\]This expression will work for any $c=0,1,2,3,…$. If we try the formula for, say, $c=8$, then the formula tells you that you can get at most 37 pieces. So, the next time you have 36 friends at your birthday party, see if you can make one piece each for you and all your friends in just eight cuts!

But why does the formula work? Perhaps the easiest way to begin tackling this question is by writing down the differences between two consecutive terms. We get the numbers 1,2,3,4,…. More generally, the difference from $(c-1)$ cuts to $c$ will be just $c$. Anything familiar about these differences? They match up perfectly with the triangle numbers, and you can obtain $p_c$ by adding up all the first $c$ differences and one. In other words,\[p_c=1+\sum_{i=1}^ c i=1+ \frac{c(c+1)}{2},\]which we expected anyway. So we have proved the general formula. But why do we get these differences? To find out, we are going to gather some intuition, so let’s take a step away from the sequence and back to the cake. Suppose you just did $(c-1)$ cuts. If you want to maximise the number of pieces after your next cut, the trick is to line up your knife so that it will pass through all $(c-1)$ cuts exactly once. By doing so, you will cut your way through $c$ pieces, splitting each bit into two smaller slices. Hence you will end up with $c$ new pieces.

Our formula is for a square cake. Actually, it also works if your cake is a circle. But will the formula work for any two-dimensional cake you could think of? The answer is no; it turns out that the formula is only useful for convex shapes. As a rule of thumb, if your cake is not convex, you can look forward to even more pieces of cake! For example, it is possible to get as many as six slices from a crescent-shaped cake in two cuts. Try it yourself! If you haven’t got a crescent-shaped cake, sketch a crescent on a piece of paper and draw straight lines on it instead.

That’s one puzzle to try out. How about a few more…?

  • What happens if the cuts don’t have to be straight? Do you still get the same formula for $c$ cuts, or will it be different?
  • Earlier I assumed that the individual pieces you get after cutting do not have to be the same size. It is quite easy to make the pieces the same size for one or two cuts, but can you do it for, say, three cuts?

But that’s enough talk for today. Now, where’s that cake?

Happy birthday to me...

Happy birthday to me…

post

Issue 05

Our latest edition, Issue 05, is available now. Enjoy the articles online or scroll down to view the magazine as a PDF.

Features

Fun

Printed versions

or

Download Issue 05 as a PDF

post

Seven things you didn’t notice in Issue 04

With just a few days to go until we launch issue 05, we thought it’d be fun to share a few bits and pieces that we hid around issue 04. If this gets you excited for issue 05, why not come to the launch party on Tuesday?!

Scorpions

Since we published the horoscope in issue 03, scorpions have been running around all over Chalkdust HQ. Three of them managed to sneak into issue 04.
Continue reading