Timetables – Hard to Read, Even Harder to Build

When you look at a train or university timetable you don’t think about how the timetable was made – you’re thinking about your trip or where your next class is.

In that moment, you couldn’t care less about all the juggling and compromising that needs to happen to get a timetable working.

Not surprisingly, though, this is a difficult process dating back many years and one that perplexes mathematicians even today.

To understand the difficulty associated with creating timetables – those timetables we all rely so heavily on – we need to understand the nature of difficulty itself.

In particular, we need to understand how it applies in a mathematical context.

Seriously, how hard can it be?

Not surprisingly, some tasks in mathematics are harder than others – but even this perception is complicated. Many important computational tasks are hard, or at least appear to be hard.

Knowing precisely what “hard” and “easy” mean has itself turned out to be extremely challenging. To really know a computational task is hard, we have to really know that there isn’t some nice efficient method waiting to be discovered that would render the task straightforward.

Our old friend timetabling is a classic example of a problem for which the precise difficulty is unknown.

I don’t get it, and my train’s leaving …

Consider a university timetable: a computer can easily check that such a timetable has no clashes but a clash-free timetable cannot (in general) be guaranteed. Because of this, finding a timetable with the minimum number of clashes is a genuine mathematical challenge.

Commercial timetabling applications can’t in general do any better than attempt to approximate the minimum number of clashes.

As yet, no-one has yet proved that timetabling cannot be solved efficiently. In fact, the ability to solve timetabling efficiently hinges on one of the foremost unsolved problems in mathematics: the so-called “P vs NP” problem.

A Millennium Problem

Roughly speaking, the “P vs NP” problem asks whether:

1) finding correct solutions to a problem (e.g. constructing a clash-free timetable) is genuinely harder task than …

2) … simply checking a given correct solution (e.g. checking to see if a completed timetable is clash-free).

Intuitively, you would believe finding a solution should be harder than checking a solution.

Think of your favourite Sudoku puzzle: checking that your solution is correct is easy – each square, column and row can only contain each number from one to nine once. But finding the solution – completing the puzzle – is hard graft.

But it’s not quite as simple as that.

In 2000, the Clay Institute chose “P vs NP” as one of seven Millennium Prize problems, with a $1 million prize for the person who solves it.

Constraint satisfaction

Algebraic and logical methods have proved particularly useful in understanding what determines the difficulty of a problem.

Among the computational problems in the NP class – i.e. problems that can’t “easily” be solved by a computer – Constraint Satisfaction Problems (or CSPs, as they are affectionately known) have received particular attention.

Any problem that involves giving values to a large collection of objects that obey some constraints is a CSP – and timetabling is one such problem.

In a school or university setting, we assign exam slots to particular subjects, obeying the constraint that subjects with common enrollment are scheduled at different times.

Map colouring is a CSP closely related to timetabling. In the above image we gave each state and territory one of three colours – red, green or blue – with the constraint that neighbouring states and territories must have different colours.

Map colouring is typical of “hard” problems in the class NP: given a successfully three-coloured map it is easy to verify that it obeys the neighbouring region constraint (so checking is easy). But in general there is no known efficient algorithm for deciding if a map can be a successfully three-coloured.

With every CSP one may associate an algebraic structure, but be warned: even by the imaginative standards of modern algebra, these structures are unusual beasts.

Numbers of the beast

In the familiar high school “algebra of numbers”, operations such as addition and multiplication are used to combine numbers to produce new ones. So, combining 1 and 2 using + gives 3.

For a CSP such as timetabling though, the role of numbers is taken by the available timetable slots, and the operations used to combine these are even more bizarre.

(How bizarre are these operations? Well, they are “technical generalisations of symmetries”, known as “polymorphisms”. You did ask!)

Despite their unusual character, these weird algebraic oddities are known to precisely determine the difficulty of a CSP.

A problem such as timetabling turns out to have very few polymorphisms: a classic hallmark of a difficult problem.

Many mathematicians and theoretical computer scientists around the world are working hard to prove it is precisely this absence of interesting properties that causes computational difficulty.

Will anyone ever solve this mighty head-scratcher? The chance of winning a Millenium Prize – not to mention $1 million – is definitely a motivating factor.

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to Peter Rowlett*


If I Had a Blank Cheque I’d … Turn IBM’s Watson Into a Maths Genius

Money should be no object when it comes to the numbers game. krissyho

Mathematics has many grand challenge problems, but none that can potentially be settled by pouring in more money – unlike the case of the Large Hadron Collider, the Square Kilometre Array or other such projects.

Maths is a different beast. But, of course, you’re offering me unlimited, free dosh, so I should really think of something.

Grand Challenges in Mathematics

In his famous 1900 speech The Problems of Mathematics David Hilbert listed 23 problems that set the stage for 20th century mathematics.

It was a speech full of optimism for mathematics in the coming century and Hilbert felt open (or unsolved) problems were a sign of vitality:

“The great importance of definite problems for the progress of mathematical science in general … is undeniable … [for] as long as a branch of knowledge supplies a surplus of such problems, it maintains its vitality … every mathematician certainly shares … the conviction that every mathematical problem is necessarily capable of strict resolution … we hear within ourselves the constant cry: There is the problem, seek the solution. You can find it through pure thought …”

Hilbert’s problems included the continuum hypothesis, the “well-ordering” of the reals, Goldbach’s conjecture, the transcendence of powers of algebraic numbers, the Riemann hypothesis, the extension of Dirichlet’s principle and many more.

Many were solved in subsequent decades, and each time it was a major event for mathematics.

The Riemann hypothesis (which deals with the distribution of prime numbers) remains on a list of seven “third millennium” problems.

For the solution of each millennium problem, the Clay Mathematics Institute offers – in the spirit of the times – a one million dollar prize.

This prize has already been awarded and refused by Perelman for resolving the Poincaré conjecture. The solution also merited Science’s Breakthrough of the Year, the first time mathematics had been so honoured.

Certainly, given unlimited moolah, learned groups could be gathered to attack each problem and assisted in various material ways. But targeted research in mathematics has even less history of success than in the other sciences … which is saying something.

Doron Zeilberger famously said that the Riemann hypothesis is the only piece of mathematics whose proof (i.e. certainty of knowledge) merits $10 billion being spent.

As John McCarthy wrote in Science in 1997:

“In 1965 the Russian mathematician Alexander Konrod said ‘Chess is the Drosophila [a type of fruit fly] of artificial intelligence.

“But computer chess has developed as genetics might have if the geneticists had concentrated their efforts, starting in 1910, on breeding racing Drosophila. We would have some science, but mainly we would have very fast fruit flies.”

Unfortunately, the so-called “curse of exponentiality” – whereby the more difficult a problem becomes, the challenge of solving it increases exponentially – pervades all computing, and especially mathematics.

As a result, many problems – such as Ramsey’s Theorem – will likely be impossible to solve by computer brute force, regardless of advances in technology.

Money for nothing

But, of course, I must get to the point. You’re offering me a blank cheque, so what would I do? A holiday in Greece for two? No, not this time. Here’s my manifesto:

Google has transformed mathematical life (as it has with all aspects of life) but is not very good at answering mathematical questions – even if one knows precisely the question to ask and it involves no symbols.

In February, IBM’s Watson computer walloped the best human Jeopardy players in one of the most impressive displays of natural language competence by a machine.

I would pour money into developing an enhanced Watson for mathematics and would acquire the whole corpus of maths for its database.

Maths ages very well and I am certain we would discover a treasure trove. Since it’s hard to tell where maths ends and physics, computer science and other subjects begin, I would be catholic in my acquisitions.

Since I am as rich as Croesus and can buy my way out of trouble, I will not suffer the same court challenges Google Books has faced.

I should also pay to develop a comprehensive computation and publishing system with features that allow one to manipulate mathematics while reading it and which ensures published mathematics is rich and multi-textured, allowing for reading at a variety of levels.

Since I am still in a spending mood, I would endow a mathematical research institute with great collaboration tools for roughly each ten million people on Earth.

Such institutes have greatly enhanced research in the countries that can afford and chose to fund them.

Content with my work, I would then rest.

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to Jonathan Borwein (Jon)*


Want To Win at Gambling? Use Your Head

When you know the numbers, things get a whole lot easier. Roberto Bouza

Gambling in Australia – Some say “punting is a mug’s game”. But is this always true, or can an astute gambler make long-term profits?

Certainly not from casino games. Casinos make profits by paying less than they should on winning bets. A roulette wheel has 37 numbers, so a gambler who bets a dollar has a 1/37 chance of winning and should receive back $37 on a winning number.

But the casino pays only $36.

On average, a gambler loses $1 for every $37 they bet: a loss of 2.7%.

This is the cost of playing the game and it’s the profit the casino makes often called the “house percentage”.

Houses of all sizes

For casino games such as roulette, Keno and poker machines, the house percentage can be calculated mathematically, and in spite of many proposed betting systems, is an immutable and unchangeable number. No strategy can be used by the punter to make the game profitable.

While gamblers may experience short-term lucky streaks, in the long run they will lose this predetermined percentage of their wagers. But a sensible casino gambler should at least be familiar with the house percentages:

Betting the win line at craps at 1.4%, or red or black at roulette at 2.7%, might be a better option than Keno or Lotto with a house percentage of over 40%.

Let’s be clear here: for every $100 bet through Tattslotto or Powerball, the “house” only pays out $60, keeping $40 for itself.

But sports betting is different.

In a horse race, the chance of winning (and hence the price for a winning bet) is determined subjectively, either by the bookmaker or by the weight of money invested by the public.

If 20% of the amount a bookmaker takes on a race is for the favourite, the public is effectively estimating that particular horse’s chance of winning at one in five. But the bookmaker might set the horse’s winning price at $4.50 (for every $1 bet, the punter gets $4.50 back), giving the bookie a house percentage of 10%.

But a trainer, or jockey with inside knowledge (or statistician with a mathematical model based on past data), may estimate this same horse’s chances at one in three. If the savvy punter is correct, then for every $3 bet they average $4.50 return.

A logical punter looks for value – bets that pay more than a fair price as determined by their true probability of winning. There are several reasons why sports betting lends itself to punters seeking value bets.

A sporting chance

In general, more outcomes in a game allow for a higher house percentage. With two even outcomes (betting on a head or tail with a single coin toss, say), a fair price would be $2.

The operator might be able to pay out as little $1.90, giving a house percentage of 5%, but anything less than this would probably see little interest from gamblers.

But a Keno game with 20 million outcomes might only pay $1 million for a winning $1 bet, rather than a fair $20,000,000. A payout of $1 million gives a staggering house percentage of 95%.

Traditionally, sports betting was restricted to horse, harness and dog racing – events with several outcomes that allowed house percentages of around 15%-20%.

With the extension into many other team and individual sports, betting on which of the two participants would win reduced a bookmaker’s take to as little as 3%-4%.

Competition reduces this further. Only the state-run totalisator (an automated system which like Tattslotto, determined the winning prices after the event, thus always ensuring the legislated house percentage), and a handful of on-course bookmakers were originally allowed to offer bets on horse racing, whereas countless internet operators now compete.

Betfair even allows punters to bet against each other, effectively creating millions of “bookmakers”.

Head or heart

Many sports punters bet with their hearts, not their heads. This reduces the prices of popular players or teams, thereby increasing the price of their opponents. The low margins and extensive competition even allow punters to sometimes find arbitrage opportunities (where betting on both sides with different bookmakers allows a profit whoever wins).

To overcome their heart, and lack of inside knowledge, many mathematicians create mathematical and statistical models based on past data and results to predict the chances of sports outcomes. They prove the veracity of their models by testing (either on past data or in real time) whether they would profit if the predictions were used for betting.

Academics call the ability to show a profit the “inefficiency of betting markets”, and there are many papers to suggest sports markets are inefficient. Of course the more successful have a vested interest in keeping their methods to themselves and may not publicise their results.

Astute punters can make sports betting profitable in the long term. But the profits made by the plethora of sports bookmakers indicate that most sports punters are not that astute.

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to Stephen Clarke*


The Million-Dollar Puzzle That Could Change The World

Cracking this mathematical mystery will make someone rich, but its value to all of us could be incalculable. Jacob Aron explains why it matters if P = NP.

Dear Fellow Researchers, I am pleased to announce a proof that P is not equal to NP, which is attached in 10pt and 12pt fonts.” So began an email sent in August 2010 to a group of leading computer scientists by Vinay Deolalikar, a mathematician at Hewlett-Packard Labs in Palo Alto, California.

It was an incendiary claim. Deolalikar was saying he had cracked the biggest problem in computer science, a question concerning the complexity and fundamental limits of computation. Answer the question “Is P equal to NP?” with a yes, and you could be looking at a world transformed, where planes and trains run on time, accurate electronic translations are routine, the molecular mysteries of life are revealed at the click of a mouse – and secure online shopping becomes fundamentally impossible. Answer it with a no, as Deolalikar claimed to have done, and it would suggest that some problems are too irreducibly complex for computers to solve exactly.

One way or another, then, we would like an answer. But it has been frustratingly slow in coming. “It’s turned out to be an incredibly hard problem,” says Stephen Cook of the University of Toronto, Canada, the computer scientist who first formulated it in May 1971. “I never thought it was going to be easy, but now 40 years later it looks as difficult as ever.”

The importance of P = NP? was emphasised in 2000, when the privately funded Clay Mathematics Institute in Cambridge, Massachusetts, named it as one of seven “Millennium Prize” problems, with a $1 million bounty for whoever solves it. Since then Cook and other researchers in the area have regularly received emails with purported solutions. Gerhard Woeginger of the Eindhoven University of Technology in the Netherlands even maintains an online list of them. “We’ve seen hundreds of attempts, and we can more or less classify them according to the mistakes the proof makes,” he says.

Deolalikar’s attempt seemed different. For a start, it came from an established researcher rather than one of the legion of amateurs hoping for a pop at glory and a million dollars. Also, Cook initially gave it a cautious thumbs up, writing that it seemed to be a “relatively serious claim”. That led it to spread across the web and garnered it widespread attention in the press, New Scientist included (14 August 2010, p 7).

In the end, though, it was a false dawn. “It probably didn’t deserve all the publicity,” says Neil Immerman, a computer scientist at the University of Massachusetts, Amherst. He was one of an army of researchers who, working in an informal online collaboration, soon exposed fundamental flaws in the proof. Deolalikar has responded to some of them and submitted an expanded version to an academic journal. Till he hears back, he refuses to comment further.

The consensus now is that his proof – like all attempts before it – is unfixable. And so the mystique of P = NP? remains unbroken 40 years on. But what is the problem about? Why is it so important, and what happens if it is answered one way or the other?

“The consensus now is that last year’s proof is false – which just adds to the mystique of the problem”

What is P?

Computing power, we are accustomed to think, is the gift that keeps on giving. Every year or two that goes by sees roughly a doubling in our number-crunching capabilities – a march so relentless that it has acquired the label “Moore’s law”, after the Intel researcher, Gordon Moore, who first noted the trend back in the 1960s.

Talk of the ultimate limits of computation tends to be about how many transistors, the building blocks of microprocessors, we can cram onto a conventional silicon chip – or whatever technology or material might replace it. P = NP? raises the spectre that there is a more fundamental limitation, one that lies not in hardware but in the mechanics of computation itself.

P = NP should not be mistaken for a simple algebraic equation – if it were, we could just have N = 1 and claim the Clay institute’s million bucks. P and NP are examples of “complexity classes”, categories into which problems can be slotted depending on how hard it is to unravel them using a computer.

Solving any problem computationally depends on finding an algorithm, the step-by-step set of mathematical instructions that leads us to the answer. But how much number-crunching does an algorithm need? That depends on the problem.

The P class of problems is essentially the easy ones: an algorithm exists to solve them in a “reasonable” amount of time. Imagine looking to see if a particular number appears in a list. The simplest solution is a “linear search” algorithm: you check each number in turn until you find the right one. If the list has n numbers – the “size” of the problem – this algorithm takes at most n steps to search it, so its complexity is proportional to n. That counts as reasonable. So too do things that take a little more computational muscle – for instance, the manual multiplication of two n-digit numbers, which takes about n2 steps. A pocket calculator will still master that with ease, at least for relatively small values of n. Any problem of size n whose solution requires n to the power of something (nx) steps is relatively quick to crack. It is said to be solvable in “polynomial time”, and is denoted P.

What is NP?

Not all problems are as benign. In some cases, as the size of the problem grows, computing time increases not polynomially, as nx, but exponentially, as xn – a much steeper increase. Imagine, for example, an algorithm to list out all possible ways to arrange the numbers from 1 to n. It is not difficult to envisage what the solutions are, but even so the time required to list them rapidly runs away from us as n increases. Even proving a problem belongs to this non-polynomial class can be difficult, because you have to show that absolutely no polynomial-time algorithm exists to solve it.

That does not mean we have to give up on hard problems. With some problems that are difficult to solve in a reasonable time, inspired guesswork might still lead you to an answer whose correctness is easy to verify. Think of a sudoku puzzle. Working out a solution can be fiendishly difficult, even for a computer, but presented with a completed puzzle, it is easy to check that it fulfils the criteria for being a valid answer (see diagram). Problems whose solutions are hard to come by but can be verified in polynomial time make up the complexity class called NP, which stands for non-deterministic polynomial time.

Constructing a valid sudoku grid – in essence asking the question “Can this number fill this space?” over and over again for each space and each number from 1 to 9, until all spaces are compatibly filled – is an example of a classic NP problem, the Boolean satisfiability problem. Processes such as using formal logic to check software for errors and deciphering the action of gene regulatory networks boil down to similar basic satisfiability problems.

And here is the nub of the P = NP? problem. All problems in the set P are also in the set NP: if you can easily find a solution, you can easily verify it. But is the reverse true? If you can easily verify the solution to a problem, can you also easily solve it – is every problem in the set NP also in P? If the answer to that question is yes, the two sets are identical: P is equal to NP, and the world of computation is irrevocably changed – sudoku becomes a breeze for a machine to solve, for starters. But before we consider that possibility, what happens if P is found to be not equal to NP?

What if P ≠ NP?

In 2002, William Gasarch, a computer scientist at the University of Maryland in College Park, asked 100 of his peers what they thought the answer to the P = NP? question would be. “You hear people say offhand what they think of P versus NP. I wanted to get it down on record,” he says. P ≠ NP was the overwhelming winner, with 61 votes. Only nine people supported P = NP, some, they said, just to be contrary. The rest either had no opinion or deemed the problem impossible to solve.

If the majority turns out to be correct, and P is not equal to NP – as Deolalikar suggested – it indicates that some problems are by their nature so involved that we will never be able to crunch through them. If so, the proof is unlikely to make a noticeable difference to you or me. In the absence of a definitive answer to P = NP?, most computer scientists already assume that some hard problems cannot be solved exactly. They concentrate on designing algorithms to find approximate solutions that will suffice for most practical purposes. “We’ll be doing exactly the same as we’re currently doing,” says Woeginger.

Proving P ≠ NP would still have practical consequences. For a start, says Immerman, it would shed light on the performance of the latest computing hardware, which splits computations across multiple processors operating in parallel. With twice as many processors, things should run twice as fast – but for certain types of problem they do not. That implies some kind of limitation to computation, the origin of which is unclear. “Some things seem like they’re inherently sequential,” says Immerman. “Once we know that P and NP are not equal, we’ll know why.”

It could also have an impact on the world of cryptography. Most modern encryption relies on the assumption that breaking a number down to its prime-number factors is hard. This certainly looks like a classic NP problem: finding the prime factors of 304,679 is hard, but it’s easy enough to verify that they are 547 and 557 by multiplying them together. Real encryption uses numbers with hundreds of digits, but a polynomial-time algorithm for solving NP problems would crack even the toughest codes.

So would P ≠ NP mean cryptography is secure? Not quite. In 1995, Russell Impagliazzo of the University of California, San Diego, sketched out five possible outcomes of the P = NP? debate. Four of them were shades-of-grey variations on a world where P ≠ NP. For example, we might find some problems where even though the increase in complexity as the problem grew is technically exponential, there are still relatively efficient ways of finding solutions. If the prime-number-factoring problem belongs to this group, cryptography’s security could be vulnerable, depending where reality lies on Impagliazzo’s scale. “Proving P is not equal to NP isn’t the end of our field, it’s the beginning,” says Impagliazzo.

Ultimately, though, it is the fifth of Impagliazzo’s worlds that excites researchers the most, however unlikely they deem it. It is “Algorithmica” – the computing nirvana where P is indeed equal to NP.

What if P = NP?

If P = NP, the revolution is upon us. “It would be a crazy world,” says Immerman. “It would totally change our lives,” says Woeginger.

That is because of the existence, proved by Cook in his seminal 1971 paper, of a subset of NP problems known as NP-complete. They are the executive key to the NP washroom: find an algorithm to solve an NP-complete problem, and it can be used to solve any NP problem in polynomial time.

Lots of real-world problems are known to be NP-complete. Satisfiability problems are one example; versions of the knapsack problem (below), which deals with optimal resource allocation, and the notorious travelling salesman problem (above) are others. This problem aims to find the shortest-distance route for visiting a series of points and returning to the starting point, an issue of critical interest in logistics and elsewhere.

If we could find a polynomial-time algorithm for any NP-complete problem, it would prove that P=NP, since all NP problems would then be easily solvable. The existence of such a universal computable solution would allow the perfect scheduling of transport, the most efficient distribution of goods, and manufacturing with minimal waste – a leap and a bound beyond the “seems-to-work” solutions we now employ.

It could also lead to algorithms that perform near-perfect speech recognition and language translation, and that let computers process visual information as well as any human can. “Basically, you would be able to compute anything you wanted,” says Lance Fortnow, a computer scientist at Northwestern University in Evanston, Illinois. A further curious side effect would be that of rendering mathematicians redundant. “Mathematics would be largely mechanisable,” says Cook. Because finding a mathematical proof is difficult, but verifying one is relatively easy, in some way maths itself is an NP problem. If P=NP, we could leave computers to churn out new proofs.

“Proving P = NP would have the curious side effect of rendering mathematicians redundant”

What if there’s no algorithm?

There is an odd wrinkle in visions of a P = NP world: that we might prove the statement to be true, but never be able to take advantage of that proof. Mathematicians sometimes find “non-constructive proofs” in which they show that a mathematical object exists without actually finding it. So what if they could show that an unknown P algorithm exists to solve a problem thought to be NP? “That would technically settle the problem, but not really,” says Cook.

There would be a similar agonising limbo if a proof that P=NP is achieved with a universal algorithm that scales in complexity as n to the power of a very large number. Being polynomial, this would qualify for the Clay institute’s $1 million prize, but in terms of computability it would not amount to a hill of beans.

Will we have an answer soon?

When can we expect the suspense to be over, one way or another? Probably not so soon. “Scientometrist” Samuel Arbesman of the Harvard Medical School in Boston, Massachusetts, predicts that a solution of “P = NP?” is not likely to arrive before 2024 (New Scientist, 25 December 2010, p 24). In Gasarch’s 2002 poll of his peers, only 45 per cent believed it would be resolved by 2050. “I think people are now more pessimistic,” he says, “because after 10 years there hasn’t been that much progress.” He adds that he believes a proof could be up to 500 years away.

Others find that excessively gloomy, but all agree there is a mammoth task ahead. “The current methods we have don’t seem to be giving us progress,” says Fortnow. “All the simple ideas don’t work, and we don’t know where to look for new tools,” says Woeginger. Part of the problem is that the risk of failure is too great. “If you have already built up a reputation, you don’t want to publish something that makes other people laugh,” says Woeginger.

Some are undeterred. One is Ketan Mulmuley at the University of Chicago. He declined to comment on his work, which is currently under review for publication, but fellow researchers say his ideas look promising. In essence it involves translating the P = NP? problem into more tractable problems in algebraic geometry, the branch of mathematics that relates shapes and equations. But it seems even Mulmuley is not necessarily anticipating a quick success. “He expects it to take well over 100 years,” says Fortnow.

Ultimately, though, Mulmuley’s tactic of connecting P = NP? to another, not obviously related, mathematical area seems the most promising line of attack. It has been used before: in 1995, the mathematician Andrew Wiles used work linking algebraic geometry and number theory to solve another high-profile problem, Fermat’s last theorem. “There were a lot of building blocks,” says Fortnow. “Then it took one brilliant mind to make that last big leap.”

Woeginger agrees: “It will be solved by a mathematician who applies methods from a totally unrelated area, that uses something nobody thinks is connected to the P versus NP question.” Perhaps the person who will settle P = NP? is already working away in their own specialised field, just waiting for the moment that connects the dots and solves the world’s hardest problem.

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to Jacob Aron*


Superman Returns – But Who’s Looking After His Water?

Is it a plane? No, it’s Smoothed Particle Hydrodynamics.

Watching films such as Superman Returns or The Day after Tomorrow, you would have seen dramatic sequences of surging water and crumbling buildings.

While doing so, mathematics was probably the last thing you thought about; but without it, scenes of this nature would be virtually impossible.

Take the 2006 film Superman Returns. In one scene, a giant spherical object smashes into a water tank releasing a huge amount of water (see below).

Traditionally, the only possible way to create this kind of sequence would be to use small models – which produce unrealistic results. Or we could create a computer simulation.

Swapping droplets for particles

These days, one of the most popular methods for simulating water is to replace fluid with millions of individual particles within a computer simulation.

And the way these particles move is determined by an algorithm that my colleagues and I invented to simulate the formation of stars in our galaxy’s giant molecular clouds.

The method is known as Smoothed Particle Hydrodynamics (SPH) and the use of SPH in Superman Returns is the work of an American visual effects company called Tweak.

Superman Returns certainly isn’t the only film to feature SPH fluid simulations: think of Gollum falling into the lava of Mount Doom in Lord of the Rings: Return of the King; or the huge alligator splashing through a swamp in Primeval.

These particular scenes are the work of people at a Spanish visual effects company called NextLimit, who received an Oscar for their troubles.

How does SPH work?

Rather than trying to model a body of water as a whole, SPH replaces the fluid with a set of particles. A mathematical technique then uses the position and masses of these particles to determine the density of the fluid being modelled.

Using the density and pressure of the fluid, SPH makes it possible to map the force acting on each particle within the fluid. This technique provides results quite similar to the actual fluid being modelled. And the more particles used in the simulation, the more accurate the model becomes.

This SPH simulation uses 128,000 particles to model a fluid.

Beyond the basics

In Superman Returns, gravity also affects how the body of water behaves (the water spills out of the water tank) and SPH can easily be adapted to accomodate this.

In addition, fluids often need to flow around solid bodies such as rocks and buildings that might be carried, bobbing along, by the flow. The SPH method can be easily extended to handle this combination of solid bodies and fluids by adding sets of particles to the equation, to represent the solid bodies.

These adjustments and extensions to SPH can be made to produce very realistic-looking results.

In industry, SPH is used to describe the motion of offshore rigs in a storm, fluid flow in pumps, and injection moulding of liquid metals. In zoology, it’s being used to investigate the dynamics of fish.

SPH and the stars

As hinted at above, it’s not just water and its inhabitants that can be modelled using this technique.

SPH simulations of star formation by Matthew Bate, from the University of Exeter, and Daniel Price, of Monash, have been able to predict the masses of the stars, and the number of stable two- and three-star systems that form from a typical molecular cloud.

In the case of stable two-star systems (known as binaries) SPH can predict the shape of the orbits in good agreement with astronomical observations.

To get this level of accuracy, millions of particles are used in the SPH calculation, and the motion of these particles is calculated on a number of computer systems that work together in parallel.

SPH is also the method of choice for following the evolution of the universe after the Big Bang. This evolution involves dark matter and gas, and the simulations have one set of SPH particles for the dark matter and one set for the gas.

An advanced SPH code – known as Gadget – used for this purpose was developed by Volker Springel. The code enables astrophysicists to predict the way galaxies form and their distribution in the universe, including the effects of General Relativity.

But for non-astrophysicists, admittedly, the movies may be more of a draw.

So next time you’re watching a film and you see large swathes of water in unusual places or doing incredibly destructive things, think about maths for a moment: without it, such breathtaking scenes would be virtually impossible.

 

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to Joe Monaghan*


Are Pi’s Days Numbered?

Pi defines the relationship between a circle’s radius and its area.

Some people have argued that Pi’s days are numbered and that other tools, such as tau, could do its job more efficiently. As someone who has studied Pi throughout his entire working life, my response to such challenges is unwavering: Pi is the gift that keeps on giving.

People call me Doctor Pi. I have played with Pi since I was a child and have studied it seriously for 30 years. Each year I discover new, unexpected and amusing things about Pi, its history and its computation. I never tire of it.

Erm, what is Pi?

Pi, written with the Greek letter π, has the value of 3.14159 …, is the most important number in mathematics. The area of a circle of radius r is πr2 while the perimeter has length 2πr.

Some Pi facts? OK

  • Without Pi there is no theory of motion, no understanding of geometry or space/time.
  • Pi occurs in important fields of applied mathematics.
  • Pi is used throughout engineering, science and medicine and is studied for its own sake in number theory.
  • It fascinates specialists and hobbyists alike.

The history of Pi is a history of mathematics

The most famous names in mathematics – Leibniz, Euler, Gauss, Riemann – all play their part in Pi’s illustrious history. In approximately 250BCE Archimedes of Syracuse rigorously showed that the area of a circle is Pi times the square of its radius.

Isaac Newton computed Pi to at least 15 digits in 1666 and a raft of new formulas for calculating Pi in the intervening years have vastly expanded our understanding of this irrational, irreplaceable number.

In my capacity as Doctor Pi – an affectionate name given to me by my students and colleagues – I have met Nobel Prize winners, pop stars and variety of colourful characters, many of whom go potty for this number.

So why the broad attraction? What is the secret of Pi’s enduring appeal? It appears in The Simpsons (doh!), in Star Trek (beam me up!), and in British singer-songwriter Kate Bush’s lovely 2005 song Pi:

“Sweet and gentle and sensitive man With an obsessive nature and deep fascination for numbers And a complete infatuation with the calculation of Pi.”

In the song’s refrain, Bush recites the first 160 digits of Pi (but messes up after 50!) Pi shows up in the movie The Matrix, episodes of Law and Order, and Yann Martel’s Mann-Booker prize winning 2001 novel Life of Pi. No other piece of mathematics can command such attention.

Memorising Pi

The current Guinness World Record for reciting these by rote is well in excess of 60,000 digits.

This is particularly impressive when you consider that Pi, having been proven irrational in the 18th century, has no known repetition or pattern within its infinite decimal representation.

A former colleague of mine, Simon Plouffe, was a Guinness World Record-holder a generation ago, after reciting Pi to approximately 4,700 digits.

Not surprisingly, there is a trend towards building mnemonics whereby the number of letters in a given word represents a digit in the series. For example “How I need a drink, alcoholic of course” represents 3.1415926. This mnemonic formed the basis of a Final Jeopardy! question in 2005.

Some mnemonics are as long as 4,000 digits, but my current favourite is a 33-digit self-referrent mnemonic published in New Scientist on Pi Day (March 14) last year.

Is Pi really infinite?

In a word: yes. So far, it has been calculated to five trillion (5,000,000,000,000) digits. This record was set in August 2010 on Shigeru Kondo’s US$18,000 homemade computer using software written by American university student Alex Yee.

Each such computation is a tour-de-force of computing science.

Estimates suggest that within the next ten to 15 years a quadrillion (1,000,000,000,000,000) digits of Pi will probably be computed. As relatively-recently as 1961, Daniel Shanks, who himself calculated Pi to over 100,000 digits, declared that computing one billion digits would be “forever impossible”. As it transpired, this feat was achieved in 1989 by Yasumasa Kanada of Japan.

It’s a kind of magic

Although it is very likely we will learn nothing new mathematically about Pi from computations to come, we just may discover something truly startling. Pi has seen off attacks in the past. It will see off attacks in the future. Pi, like its inherent magic, is infinite.

The battle continues.

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to Jonathan Borwein (Jon)*


Pascal’s Triangle and Polygonal opsgf’s

The diagram above illustrates a surprising correspondence – if you take the reciprocal of a particular polynomial whose coefficients match the d+1 row of Pascal’s Triangle, you obtain a formal power series whose coefficients are precisely the elements in the dth column of the triangle.

The case for the third row is shown above (row and column numbering starts at 0 in Pascal’s Triangle), and the case for the fourth row is shown in the diagram below. To actually work out the power series that comes from the reciprocals (well, at least the first few coefficients), the grid method of dividing polynomials works well (I think).

In this way, the rows of the triangle  provide all the information required to obtain the columns – a nice correspondence between a finite sequence and an infinite one.

You’ll see this correspondence if you spend time investigating the “ordinary power series generating functions” (opsgf’s) for the higher dimensional triangular numbers. The row polynomials are just (1-x)^(d+1), while the columns correspond to formal power series whose coefficients are the d-dimensional triangular numbers. A great place to learn about these opsgf’s is H. Wilf’s book generatingfunctionology.

You can uncover the general opsgf for higher dimensional triangular numbers by starting with the (1-x)^(-1) rational function, and applying Wilf’s ‘rule 5’ from chapter 2 of generating functionology.

Applying a few other rules, you can obtain an opsgf for the k-polygonal numbers (= 4 is squares, = 5 is pentagonals, = 6 hexagonals, etc.).

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to dan.mackinnon*


A Family of Sequences and Number Triangles

The triangular numbers (and higher triangular numbers) can be generated using this recurrence relationship:

These will form Pascal’s triangle (if we shift the variables n->n+d-1 and d->r, we get the familiar C(n,r) indexing for the Pascal Triangle). The d=2 case gives the usual “flat” 2d triangular numbers, and other d values provide triangular numbers of different dimensions.

 

It turns out that recurrence relation can be generalized to generate a family of sequences and triangles. Consider this more general relation:

Doing some initial exploring reveals four interesting cases:

The triangular numbers 

With all these additional parameters set to 1, we get our original relation, the familiar triangular numbers, and Pascal’s triangle.

The k-polygonal numbers 

If we set the “zero dimension” to k-2, we end up with the k-polygonal numbers. The triangular numbers arise in the special case where k=3. Except in the k=3 case, the triangles that are generated are not symmetrical.

 

Below is the triangle generated by setting k=5.

The symmetrically shifted k-polygonal numbers

As far as I know, there is not a standard name for these.  Each k value will generate a triangle that is symmetrical about its center and whose edge values are equal to k-2. For a given k value, if you enter sequences generated by particular values of d, you’ll find that some are well known. The codes in the diagrams correspond to the sequence ids from the Encyclopedia.

 

Here is the triangle generated by k=4:

And here is the triangle generated for k=5:

The Eulerian numbers (Euler’s number triangle)

This is a particularly nice way to generate the Eulerian numbers, which have a nice connection to the triangular numbers. There is a little inconsistency in the way the Eulerian numbers are indexed, however. For this formula to work, it should be altered slightly so that d>0. The resulting formula looks like this:

And the triangle looks like this:

It is surprising that so many interesting and well known sequences and triangles can be generated from such a simple formula, and that they can be interpreted as being part of a single family.

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to dan.mackinnon*


Farey, Ford, & Fathom

Chapter 3 of Hardy & Wright’s An Introduction to the Theory of Numbers involves Farey sequences – which, in addition to showing up in serious number theory books, are an interesting, accessible, and popular topic in recreational mathematics.

Since I am a committed constructivist (in at least a few senses of the word) I thought it would be nice to come up with an activity with Farey sequences that could be carried out without too much advance discussion about what they are. What I came up with is a Fathom activity that starts with some simple but odd looking data that allows you to construct some very interesting plots and displays. The idea is that you will get a feel for what a Farey sequence is by using the data to build the sequence and by looking at the results from different perspectives.

Step 1. Import some data

Here is the data to import into Fathom. It should create 33 cases with two attributes n, and d.

n d

0 1

1 10

1 9

1 8

1 7

1 6

1 5

2 9

1 4

2 7

3 10

1 3

3 8

2 5

3 7

4 9

1 2

5 9

4 7

3 5

5 8

2 3

7 10

5 7

3 4

7 9

4 5

5 6

6 7

7 8

8 9

9 10

1 1

 

Step 2. Add some more attributes

After importing this data, you should create the following attributes

i = caseIndex

q = n/d

dist = q – prev(q)

mediant = (n+prev(n))/(d+prev(d))

d_mediant = mediant – prev(mediant)

disp = concat(n,”/”,d)

The meaning of the “mediant” attributes will become clearer after you read about Farey sequences.

 

Step 3. Explore some plots

Plots you could try creating are:

  1. A) n on the y axis and d on the x axis.
  2. B) dist on y, i on x (a filter of i>1 makes sense here)
  3. C) d_mediant on y, i on x (a filter of i>2 makes sense here)
  4. D) mediant on y, q on x (adding a function y=x makes sense here)
  5. E) d on y, q on x
  6. F) dist on y, q on x
  7. H) q on x with no other attributes

While creating these plots, you should be thinking about describing the sequence that the cases represent. What kinds of numbers are they, what values do they have (do they lie in a certain interval?), how close are they to one another?

Step 4. Create a nice display

One of the more visually interesting thing you can do with the Farey sequence is to display its associated Ford circles. This can be done by adding two new sliders and by editing the display settings for the collection.

 

Add the sliders “scale” and “shift,” and give them these initial values:

scale = 400

shift = 150

Now on the collection inspector, click on the Display tab, and edit the formulas for these attributes

x= q*scale +shift

y = scale/(2*d^2)

image = blueCircleIcon

width = scale/(d^2)

height = scale/(d^2)

caption = “”

If you pull open the display, you will see the initial iterations of a fractal pattern known as the Ford Circles that are generated by the Farey sequence. Here is what it should look like:

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to dan.mackinnon*


Another Triangular Number Formula

The double recurrence relation that defines the higher triangular numbers is a simple one – it is no surprise that they turn up so often.

The geometric interpretation is stacking: For a given dimension d, you get the n+1 d-triangular number by stacking the nth d-1 triangular number (the gnomon) onto the nth d-triangular number.  The zero dimensional triangular numbers are just the sequence: 1, 1, 1, 1,…, presumably counting stacks of nothing. The one-dimensional triangular numbers are the naturals: 1, 2, 3, 4, …, made by stacking the ones of the one-dimensional case. The two dimensional triangular numbers stack the naturals: 1, 3, 6, 10, …, the three dimensional triangular numbers make pyramids of the triangulars: 1, 4, 10, 20, ….

If you write out a difference table for the higher triangular numbers, you end up with Pascal’s triangle. This suggests a nice formula for the triangulars in terms of binomial coefficients:

From this, you can obtain another recursive formula that you can use when working with higher triangular numbers (this is the “another” formula for this post):

If you vary the defining recurrence relation so that the initial “zero dimensional” value is a number other than 1, you get the other polygonal numbers (square, pentagonal, hexagonal, square-based pyramidal, etc.). In particular, if you let the zero-dimensional value be k-2, you obtain the k-polygonal numbers (k-2 corresponding to the number of triangles in your k-sided polygon).

It turns out there is a nice formula for these in terms of binomial coefficients as well:

For more such insights, log into www.international-maths-challenge.com.

*Credit for article given to dan.mackinnon*