I'm game if you are

Pairing people off can have some nasty and unexpected side effects. Occasionally, it works: Torvill and Dean spring to mind, as do Crick and Watson. But Blair and Brown, it is becoming increasingly clear, was not a match made in heaven.

Further alliances are likely to be struck in the next few weeks, and similarly disastrous long-term consequences may ensue. What the Labour Party needs now, before it's too late, is the help of a branch of mathematics known as game theory.

Game theory has proved useful to politicians in the past. When John Nash (of A Beautiful Mind fame) invented his "Nash equilibrium", a mathematical trick for settling arguments in a way that offers all parties a mutual advantage, it was applied with great success to cold war politics. It has also proved useful more recently: a government auction of bandwidth to mobile-phone companies in 2001 used Nash's equations to fetch as high a price as possible while keeping the phone companies happy.

So perhaps politicians could use game theory to settle their internal differences. A framework already exists. The "stable marriage problem" is designed to form long-lasting, strife-free alliances.

The maths begins with a familiar scenario - a group of people eager to pair off. The sticking point, as always, is that some people are more desirable as partners than others. The chances are that there is one person who dominates everybody's wish-list, meaning that if the process is left to itself, almost everybody will end up dissatisfied.

But there is a way forward. First, everyone has to rank all the potential partners in order of preference. David says he could work with Andy more easily than he could with Ed, for example. Andy, on the other hand, would rather work with Diane than with David. Unfortunately, Diane ranks Andy lowest of all. And so it goes on, until all the lists are in.

Once the rankings are in, you look for a set of pairings where everybody has the highest-ranking partner that will have them. In 1962, the mathematicians David Gale and Lloyd Shapley proved that it is always possible to find an outcome that is entirely stable - you really can create a situation where there is no partner swap that will make anyone any happier. It's a perfect recipe for long-term stability.

In half a century, however, the stable marriage problem has found only limited practical use. Dating websites could use it to solve all their clients' problems, but perhaps it suits them better to keep dissatisfaction levels high. The only documented case of everyday use seems to be in finding hospital placements for graduating doctors.

This is the perfect moment to apply it to politics. Labour could pioneer a scientifically formed leadership that will take us into an era of stable political partnerships. The downside? Exceedingly dull memoirs.