‘Magic’ card trick

I’ve just heard that our maths theme for this year’s Edinburgh Science Festival is going to be ‘Maths is Magic’.  That got me thinking about magic tricks that involve mathematics, and I found out about a really great card trickplaying cards.

You will need:

  • A normal deck of playing cards
  • A lovely assistant
  • The ability to memorise 6 things

The trick goes like this.  Ask a random member of the public (let’s call him Bob) to choose 5 cards from the deck.  Bob can shuffle the deck first if he wishes, and he can pick the cards at random or make a deliberate choice.  When he has his 5 cards, ask him to hand them to your lovely assistant.  Your assistant will then hand you 4 of the cards, and your job is to correctly predict the 5th.

How is this possible without some sort of secret hint from your assistant?  Well, there is going to be a secret hint, and the secret hint is going to be the order in which they hand you the first 4 cards.

If you choose any 5 playing cards, it is inevitable that two of them will have the same suit.  One of these will be the card that you will predict, and the other will be the first card that your assistant gives you.  So, after the very first card you receive, you already know the suit of the mystery card.  This narrows down your prediction to 12 possible cards.

Imagine a clock with 13 numbers on it instead of 12.  If I give you any two distinct numbers on the clock, you will be able to get from one to the other in 6 steps or less by travelling clockwise.  For example, if I give you the numbers 2 and 7, you can get from 2 to 7 in five steps (obvious).  If I give you 2 and 10, you can get from 10 to 2 in five steps too: 10-11-12-13-1-2.13-hour clock

This scenario applies to the two cards of the same suit that Bob chose.  Make your assistant choose the ’smaller’ of the two cards to give to you first, i.e. the one from which you can travel around clockwise to get to the other one in 6 steps or less.  Now your assistant has 3 cards left in which to convey to you a number between 1 and 6.  You will add this number to the first card you were given, calculate the new number using the clock method, and hey presto you will correctly predict the mystery card!

How do we get a number between 1 and 6 using the remaining three cards?  Well, if you are given three objects there are 6 different ways of arranging them in a straight line.  Order your three cards from smallest to largest by number; if two cards have the same number then we’ll say that the smallest is clubs, followed by diamonds, hearts and then spades (alphabetically).  For example, 4,8♣,8 or J♣,J,J♠.  So we have a smallest (S), middle (M) and largest (L) card. You’ll need to memorise the following set of combinations:

  1. S-M-L
  2. S-L-M
  3. M-S-L
  4. M-L-S
  5. L-S-M
  6. L-M-S

Thus the order in which your assistant hands you the three cards gives you a number between 1 and 6.

Worked example (from the point of view of the assistant): Suppose Bob chooses the cards 4, A, K♣, 2 and 10.  First step: identify a suit that occurs twice.  In this case it’s hearts.  You actually have a choice since there are three cards which are hearts!  Pick the smallest two, the 2 and 4.  Give the 2 to the magician and keep the 4 as the mystery card.  The magician now knows that the mystery card is a heart and that it is at most six numbers away from the 2.  Your job is to communicate that the mystery card is two numbers away from the 2.  The three remaining cards are A (S), 10 (M) ,K♣ (L) .   Remembering the code you learnt earlier, you hand the cards to the magician in the order A (S), ,K♣ (L), 10 (M).  If the magician has learnt the code correctly, he can now confidently say that the last card in the hand is the 4 of hearts.

Bob is flabbergasted by the amazing magical feat you have performed, while you can smile inwardly at the amazing feat of mathematics you have demonstrated.

Fractal snowflakes

McHaggis on the Christmas tree

McHaggis as a Christmas decoration

Friends, readers, random strangers!  I hope you have all had a very merry Christmas (which of course is Sir Isaac Newton’s birthday, so those of us of a non-religious disposition may celebrate too) and enjoyed the beautiful snow we had last week.  I journeyed from Edinburgh to London for the festive season and was flabbergasted at the beauty of the snow-covered fields with the camouflaged sheep in them.  Poor McHaggis, my son, is not quite so well-camouflaged as I, what with his black face and wee feet, so unfortunately he was discovered and used by the cruel humans as one of their Christmas decorations.

As for myself, I have been staying amused by pondering the nature of the Maslov Index (don’t ask – I don’t understand it…) and by regaling my guests with tales of the infinity of infinities that exist in the mathematical realm.  It is always good to test out ideas on the (adult) general public before letting them loose on school pupils!

Anyway, it being Christmas and all, I thought I should write a post on something more festive than usual.  So I’m going to tell you about the idea of fractals and, in particular, how to make (and bake!) yourself a fractal snowflake.

A fractal is an shape with the property that any zoomed in part of it looks the same as the original shape.  One example from real life is a coastline.  A coastline looks pretty wiggly from a distance, but when you zoom in on a small part of the coastline it still looks wiggly!  If you zoom in further, till you can see the actual pebbles, it still looks wiggly, and even on a molecular level it is still…wiggly.  The difference between real life and mathematics is that in real life there is a limit to how far you can zoom in, since you can’t go any further than the atoms and quarks.  But in the mathematical world, you can zoom in infinitely far.

Another real-life place to find fractals is snowflakes.  Generally, if you zoom on on any of the ‘leaves’ of a snowflake, you’ll find that the zoomed-in bit looks the same as the whole leaf.

snowflake

Snowflake

One way of making fractals is by a recursive method, i.e. you repeat the same set of instructions over and over again.  We are going to make a fractal snowflake using a method described by Helge von Koch (whence it is called the Koch snowflake).  First, draw an equilateral triangle.Then replace each side of the triangle with the following shape:

This gives us the following nice star shape:

Now repeat!  Wikipedia has a nice video of the Koch snowflake evolving in a few time steps, as well as some more information about its mathematical properties.  Sci-Fun also have a good article about the Koch snowflake, proving why it has an infinite perimeter but a finite area.

Try starting out with a random polygon and a rule for changing it, and see what happens!  It’s easy to make beautiful, symmetric, intricate pictures that would look great on the front of a Christmas card.  Then, if you get bored with that, you can try baking your own fractal cupcakes!  Have fun!

N.B. I started writing this post just after Christmas, and then stuff happened and now it’s 2010!  Sorry about that.

Tam Dalyell Christmas Lecture

Professor Chris Bishop

Professor Chris Bishop

Last Wednesday I was fortunate enough to be in the audience when Chris Bishop gave the Tam Dalyell Christmas lecture and accepted this year’s prize for science communication. Chris works in the Informatics department at Edinburgh and is also employed by Microsoft to do research on Machine Learning.  I loved the lecture not so much because I learnt new things about computers (although I was intrigued by the idea of using DNA as a computer) but mostly because I came away with so many ideas about maths outreach.

I’ve often complained that mathematics is the hardest of the science subjects to design outreach activities for.  In Physics and Chemistry there are many cool experiments – you can blow things up, make things really hot/cold (liquid nitrogen is always fun!), play with strange materials or recreate the conditions on, say, Mars.  Biology is directly relevant to all humans, no explanation required, whilst Technology and Computing are automatically cool because the future will depend so heavily on them.  On the other hand it is very difficult to motivate mathematics for its own sake; to explain the beauty without having to resort to explaining how it is useful in other subjects.  It is difficult to design physical experiments to illustrate things that we’ve only seen inside our heads, only manipulated using abstract symbols instead of hands.

Well, Chris Bishop has taught me that it is possible!  I just need to have a little more imagination, a little more ambition, and possibly access to the equipment in a chemistry or physics lab…  Here’s a clip of Chris explaining exponential growth using a sequence of mousetraps with ping-pong balls in them.  One ball is dropped onto one mousetrap, causing both the old and the new balls to rebound.  Each of those hits one other mousetrap, releasing four balls, etc.  A very simple but effective visual experiment that explains more in 5 seconds than a graph might in half an hour.  In another experiment, Chris gave the audience an idea of very small numbers by blowing up a snowman (it looked like cotton wool but was made of some kind of explosive) in a very short amount of time.

Another thing I learnt from the lecture is that if you have a really cool experiment, it is reasonably easy to find an excuse to fit it into your talk!  At one point Chris had a balloon filled with oxygen and hydrogen which he enjoyed exploding with a loud bang, just to make the point that chemical reactions usually only go in one direction.  Towards the end, he mixed liquid nitrogen with boiling water just to fill time whilst waiting for another experiment.  Both of these are visually and audibly stunning – they wake the audience up and get them listening to you, ready for what you *actually* want to say afterwards.

I’m already looking forward to my next maths communication challenge to see if I can come up with exciting visual and physical props to make maths sound just as cool as Chris made computing.  I’m sure it can be done!

Torus knot signatures, Part 3

Today we are going to learn some basic theory about slice knots. (Don’t worry – the relationship between this and the first two posts will become clear in due course!)

Every knot can be constructed as the edge of a 2-dimensional surface.  For example, the trefoil:

A trefoil bounding a surface

A trefoil bounding a surface (Picture credit: SeifertView)

(The wonderful program SeifertView is free to download and will produce a surface for any knot you give it.)

You will notice that this surface has a hole in the middle of it.  It turns out that only an unknotted piece of string can bound a surface with no holes in it (such a surface is called a disc). But what if we had another dimension of space in which to play?  Would that affect the result?

The 4th dimension is hard, if not impossible, to picture, so let’s start with a 3-dimensional analogy.  If we have a curve in 2 dimensions that intersects itself, it creates a kind of ‘hole’ in space.  But if we push the curve into the third dimension then the intersection point goes away and so does the hole:

Pushing a loop into 3 dimensions

Pushing a loop into 3 dimension

The question is: is it possible to remove holes in surfaces by pushing them from 3 dimensions into 4 dimensions?  In the case of surfaces bounded by knots, the answer is: sometimes.  These special knots are called slice knots.

It is, in general, very difficult to decide whether a knot is slice or not.  Mathematicians have worked out one way of telling if a knot is not slice: compute a number, called a signature, and if it is not zero then the knot is not slice.  If you know a little bit about matrices, read on and I will tell you how to compute the signature.

First, take your knot and find a surface that it bounds. (This is called a Seifert surface).  Then, draw a curve on the surface around every hole that you see, like this:

Curves around all the holes on a surface

Curves around all the holes on a surface

We want to make a matrix that contains all the data of how these different curves link and knot around each other.  First, give each curve a number, then push each curve off the surface in turn and calculate how many times it links with all the other curves.  We enter the linking number of the pushed off curve i with another curve j into the (i,j)th entry of our matrix.  For example:

Pushing each curve off the surface in turn

Pushing each curve off the surface in turn

For this knot, our matrix is

SeifertMatrixNow, whenever you have a square matrix you can compute a set of numbers called eigenvalues.  These are numbers λ that satisfy the equation Mv=λv, where M is our matrix and v is some vector. (If you would like to learn more about eigenvalues, take a look at the Wikipedia article.)

The signature of a matrix is

(the number of positive eigenvalues) – (the number of negative eigenvalues)

and it is a deep theorem that slice knots will always have signature equal to zero.

Next time we will learn about the signature of torus knots, and we will see how they are tied in to the number theory we learnt about in the first two parts of this blog-series.  Stay tuned!

EUSci seminar

EUSci is the Edinburgh University Science magazine, and this evening they held the first lecture in a new seminar series. Before the talks there was pizza and drinks and plenty of opportunity to chat to other scientists: G and I got talking to a master’s student in ‘Ecological Economics’ (or ‘Economics for hippies’ as he put it) and a new PhD student in Chemistry (she gets to play with big machines that do lots of squeezing).

There were three talks over the course of the evening, all fairly biologically based.  I was very impressed by the quality of the speakers, who were only graduate students, and I’d like to tell you a bit about the topics they introduced us to.

First up was Katie Marwick talking about ‘Cognitive Enhancement’.  There are some drugs on the market that are designed to help people with mental disorders, for example, Ritalin for ADHD and Donepezil for Alzheimers, but the same drugs administered to ‘normal’ subjects resulted in an increase in some cognitive functions, such as alertness, memory and awakeness.  These drugs appear to have no short-term side effects but the long-term effects of regular use are unknown. Katie raised a lot of ethical questions associated with these kinds of drugs:

  • Should they be legalised so that you can get them without a prescription?
  • Is it fair for some people to take them, for example, before an exam?  Is this any more unfair than giving some children a private education or raising them with more books to read as they grow up ?
  • Should some people be forced to take these drugs?  For example, doctors on night shifts to prevent them making as many mistakes?
  • Would taking these drugs alter your personality?  If you considered yourself an absent-minded person then would removing that trait change who you see yourself as?
Sheep on St Kilda

Sheep on St Kilda

Next was Adam Hayward talking about ageing in wild sheep populations.  A particular sheep population on St Kilda, to be precise.  He spends his time researching how much of an effect the environment has on the aging process of an animal.  To do this, he measures the amount of a certain parasite in the faeces of the sheep to see how good the sheep are at fighting off disease.  Firstly, it turns out that female sheep are much better at fighting the parasites than males, and they also have a life span that is about twice the male one (15 years compared with 7 or 8 years, although castrated males can live up to 17 years!). Adam also found that sheep who had lived a better life got better at fighting the parasites as they got older, whilst those who had had particularly hard lives (usually through weather conditions) tended to have more parasites in their bodies as they got older.  So, some lessons for humans: eat well and live happily (and get castrated!) if you want to have a better old age!

Finally we had Sarah Kabani who does her research on the parasite causing African Sleeping Sickness.  The parasite has a hard life, since it must survive both in the stomach of the tsetse fly (where it is attacked by gastric juices) and in the human bloodstream (where it is attacked by the immune system, but at least has plenty of sugar to feed on).  Sarah studies the transition in the genome of the parasite as it changes from ‘fly state’ to ‘human state’, using some fairly impressive-sounding technology.  Apparently they can print all 8,000 of the parasite genes onto a single microscope slide, and then they can make the genes glow at various intensities to show which ones are being used at which times.  The hope is that they can identify the genes which are most crucial to the parasite’s survival and then create drugs which can target these particular genes.

I very much enjoyed listening to all the talks, not just to learn more about the science but also to learn how scientists in other areas carried out their research.  There is quite a difference between a mathematician sitting with a pen and paper (and perhaps a computer) and biologists who are examining faeces, testing drugs on patients or scrutinising tiny glowing dots of genes.  I look forward to the next EUSci seminar!

Torus knot signatures, Part 2

Let’s quickly recap what happened last time.  We started with two coprime numbers, p and q, and for every number n which was neither a multiple of p nor q we wrote n as

n=ap + bq

where 0<a<q.  We defined the function j(n) as +1 if b was positive, and -1 if b was negative (and zero if n was not an allowed number).  The function s(n) was then defined as the running total of the j’s; for example, s(3) = j(1)+j(2)+j(3).

The question was then: how do we predict the function s?  The graphs we saw in the last post showed that s had all sorts of bumps and wiggles that varied a lot for different values of p and q.  How should we go about discovering the pattern?

Let’s try condensing all the data of s into just one number.  Then we can compare the value of this number over lots of values of p and q.  The number I’m going to choose is ‘the area under the graph of s’.  That’ll be the area inside the ‘V’ shape of the graph, since s is always negative.  It is easy to set up a computer program to calculate this value for lots of different p and q less than 100.  Here is the result:

Value of the area under the graph of s for different values of p and q

Value of the area under the graph of s for different values of p and q. Red=small...Bluer=bigger.

Don’t worry about the dark spots in the picture: those are the points when p and q weren’t coprime, so there was no graph to find the area of.  The exciting thing is the very regular colouring of the graph!  The values of the area are changing very predictably with p and q, despite the graphs themselves being very unpredictable.

What is this new ‘area’ function?  What is it really measuring and how can we find a formula for it?  Tune in next time for a deeper explanation of what is going on here…

Torus knot signatures, Part 1

I want to tell you about the current mathematics I’m working on, because it’s exciting, surprising, beautiful, deep, and easy to explain!  Everything that a good piece of maths should be.  I’m going to have to explain it in a few parts though, leading you through the different steps I had to solve to get to the solution.

Here’s a problem to get you started.  I’m going to give you two numbers, p and q, which are coprime.  That means they have no common factors.  For example, I can’t give you the numbers 9 and 12, since both of them are divisible by 3.  But I can give you the numbers 9 and 10 since 9=3×3 and 10=2×5, and there is no overlap. Ok.  Now I give you another number n between 1 and pq-1, such that n is neither a multiple of p nor a multiple of q.  Your task: take n and keep minusing multiples of p from it until you get a number that is a multiple of q.  Then tell me whether the multiple of q is positive or negative.

Let’s do an example.  Suppose p=3 and q=5.  I need to give you a number n between 1 and 14, so let’s start with the simple n=1.  First we try 1-3=-2.  Not a multiple of 5.  So we try 1-(2×3) = -5.  Success!  And -5 is negative.  Now let n=8.  Try 8-3=5.  First time lucky! And this time we got a positive number.

For particular numbers p and q, we are going to do this for all possible n.  So if p=3 and q=5, we have to find the answer for n=1,2,4,7,8,11,13,14.  If the answer is positive, put j(n)=1, and if it’s negative we put j(n)=-1.  So, for these particular values of n, the corresponding values for j are -1,-1,-1,-1,1,1,1,1.  Now we keep a running total, and call that number s.  So the values for s are -1,-2,-3,-4,3,2,1,0.  Actually, for reasons that I will explain later, the interesting number to look at is 2 times s.

Let’s draw a graph of the function 2s and see what it looks like.  Does it always go “minus minus minus plus plus plus”?  Well, for p=2, the answer is ‘yes’, no matter what value you choose for q.  Here’s the graph of p=2,q=25, with the values of n running along the bottom and the value of 2s running up the side.

p=2, q=25

p=2, q=25

Notice the lovely ‘V’ shape that it makes.  The values of s decrease until a certain point, and then increase again.

Let’s see what happens when p=3.  Here’s the graph for p=3, q=10:

p=3, q=10

p=3, q=10

Oh no, what happened?  The graph is all wiggly at the bottom!  Minus, plus, minus, plus – what’s going on?  It’s obviously not a proplem with the number 3, since our previous example of p=3, q=5 worked out fine.  Maybe we just picked a funny combination of numbers.  We had better try another pair and see what happens there.  How about p=7, q=16?

p=7, q=16

p=7, q=16

Even more wiggles!  Yikes, it seems that this function is going to be pretty unpredictable.  The pattern seems to be very different for every p and q.  How on earth are we going to get a formula that tells us what is happening?

Tune in next time for more clues…

Mathematics fable

Hello everyone, Haggis reporting again after far too long away!  The summer ended up being more about doing maths rather than talking about it, and as we speak I am heavily embroiled in the mysteries of torus knots and signatures, not to mention quadratic forms and the pesky prime 2.  Perhaps I shall have a rant about the number 2 one day…

Helen Jackson and Adam Brewster

Helen Jackson and Adam Brewster

But today I wanted to tell you about another science communication endeavour that is starting in the maths department this month.  We’ve been approached by the animation company Binary Fable, which consists of Helen Jackson and Adam Brewster, who have a great idea for a new project.  They want to make 3 short animated films which involve the main character using mathematics to solve a problem.  Alongside that, there will be a website which will contain follow-up information about the maths in each film, together with a series of challenges for the public to solve.

Helen and Adam are looking for some ‘mathematicians in residence’ to supply ideas for the films, to blog on the website and to help construct the challenges to go with the films.  Construction work on the animation will probably not happen until April, ready to get the first film out when the new academic year starts in September.

Sadly I’m going to be too busy working on my Möbius strip project with Peter, along with helping Julia finish her PhD, to be a main point of contact for this project, but hopefully I can throw in some cool ideas of knot theory and topology to get them thinking!  Who knows, maybe there’ll even be a way to link this project to the Möbius one!

It’s always great to find new ways of bringing maths to the public, so I am very excited to see how this new method will proceed.  Stay tuned for more news!

Opportunities to inspire

It looks like the summer and autumn are going to be busy times in terms of science communication! In addition to developing the non-orientability exhibition I’ve agreed to help out with the following:

  • Kickstart workshop, Wednesday 22nd July. Children aged about 16 from Edinburgh and the Lothians will descend upon the Edinburgh universities for a week in order to experience higher education. Each day they have the opportunity to do workshops in a couple of subjects to see what they are like, and hopefully find something they’d like to study at university one day. I will be giving a 20-minute talk on Knot Theory (either braids or DNA) to persuade them that maths is beautiful and creative, as well as useful in the real world.
  • Maths masterclass, October/November. Every year Heriot-Watt and Edinburgh Uni run a series of about seven ‘maths masterclasses’ for bright 13-year olds. The sessions aim to give students a feeling of what research-level mathematics is all about through talks by mathematicians and then more in-depth activities. This year there is a vacancy for a speaker, and through a fortunate encounter with Robert Weston at a dinner party, my name came up! It’s going to be a lot of work preparing two hours’ worth of material, but I think the rewards will be worth it.

But for the moment, back to this PhD thingy. My flatmate Julia needs all the help she can get…

Surgery update

So, it’s been a little while since I last wrote and many of you are wondering what has happened about my surgery illustrations. I am wondering about this myself, not having heard from Erica (the journalist) in nearly two weeks now. The latest news was that the editor was considering hiring a professional animator (they’re willing to pay him, but not poor Haggis!) but they wanted my pictures to give him an idea of what was needed. I duly sent them off, all annotated and everything, but have no idea what the animator is going to do with them or when this article is going to appear.

Seeing as I’ve made these pictures I may as well give you (my loving readers) a brief description of what surgery is to show them off again.

So, you start off with your favourite manifold. A manifold is a mathematical space or shape which looks flat if you zoom in on any particular bit of it. For example, a circle looks curved from a distance but if you zoom in far enough then it’ll look like a straight line. Similarly, we live on a sphere but walking about in our everyday lives we think we’re on a flat surface. (Some people actually still think we live on a flat earth!) My favourite 2-dimensional manifold is a torus (or doughnut):

A 2-dimensional manifold called a torus

A 2-dimensional manifold called a torus

To start off the surgery procedure we have to cut out a “disc times a sphere”. In this case we will cut out a 1-dimensional disc (which is a line) times a 1-dimensional sphere (which is a circle).

Circle times a line is a cylinder

Circle times a line is a cylinder

This gives us the following picture:

Torus minus cylinder

Torus minus a cylinder

The other half of the surgery procedure is to glue back in a different “disc times a sphere” along the edge where the other one was removed. In this case we will glue in a 2-dimensional disc (which is a filled-in circle) times a 0-dimensional sphere (which is two points – the boundary of the 1-dimensional disc).

Disc times two points is two discs

Disc times two points is two discs

Gluing these discs in gives us:

Gluing in two discs

Gluing in two discs

Finally, because I am a topologist I can pretend that this shape is made of plasticine and I can squeeze and push it about however I like (so long as I don’t make any holes in it). Hopefully you will agree with me that the simplest way to display this shape (after a bit of squeezing) is a sphere:

A sphere

A sphere

So what surgery has done is to take a shape with a hole in it (the torus) and change it into a shape with no holes in it (the sphere). This is the general idea of surgery theory: to try and make shapes simpler. We can do it with high-dimensional shapes too (in fact, this is where it is most useful!) but this is very hard to visualise.

I hope you have enjoyed my few small pictures, and I will post again when I know more about the Kervaire article.  Comments, as always, are welcome.