The excitement of mathematical discovery combined with the eccentricities of great mathematicians is a winning formula in fiction and film, writes Arminta Wallace.
Picture the scene. A small town in India: a class of 11-year-olds, studying mathematics. Their teacher explains that if you divide any number by itself, you always get one. If you have 16 bananas and you divide them among 16 people, each person will get one banana. If you have 10,000 bananas and divide them among 10,000 people, each will get one banana. Simple. It's an infallible rule, the teacher says.
Then one small boy raises his hand. But what happens, he asks, if you divide no bananas among no people? Srinivasa Ramanujan wasn't just the class wise-guy. He was a mathematical genius who - largely by asking awkward questions and pursuing an original path - grew up to be one of the most celebrated mathematicians of the 20th century.
His story is also the basis of David Leavitt's mammoth new novel, The Indian Clerk. The book tells the story of the years Ramanujan spent at Cambridge at the invitation of his mentor, the English mathematician GH Hardy. While pure mathematics might seem like an unlikely subject for fiction, the book is the latest in a long list of artistic endeavours to document a world that used to be located off the end of the creative scale.
Remember A Beautiful Mind, Ron Howard's big-screen version of the life of US mathematician John Nash? It received four Academy Awards in 2002, including one for its lead actor Russell Crowe, as well as unleashing a storm of controversy among the mathematical set about its relationship - or lack of it - to Nash's "real" life. Meanwhile, Dan Brown's Da Vinci Code was busy selling Fibonacci numbers, Pythagorean triangles and the concept of the golden ratio to the Dolce & Gabbana generation.
So what is it about mathematics that makes it a cultural topic du jour? One possible explanation is sheer terror. For those of us who emerged from school traumatised by years of struggle with vectors, calculus and line equations, mathematics ranks second only to snakes in the nightmare stakes. Like snakes, however, maths has a peculiarly mesmeric quality. Or maybe it's more accurate to say that when we're released from the responsibility to always come up with the correct answer, we can relax and have fun with some of the more mind-boggling mathematical questions.
Maths, as the young Ramanujan was quick to recognise, can take you straight to the heart of what we call "reality" quicker than almost anything else. One minute you're talking about people and bananas; the next you're staring infinity in the face.
And then - speaking of people and bananas - there are mathematicians. As Leavitt puts it in The Indian Clerk, "pure mathematics holds a mysterious attraction for cranks of all stripes". In the best literary tradition, he admits to having taken some rather large fictional liberties. Even so, the three characters at the centre of his book are a novelist's dream.
In fact, you couldn't make them up: Ramanujan, the self-taught savant who rises like a star in the east, claiming that his outlandish equations are being written on his tongue during the night by a Hindu goddess; Hardy the rational atheist who is also profoundly shy, socially inept and unhappily gay; and Littlewood the Byronic bachelor who likes to stroll across the Cambridge quad, dressed only in a skimpy towel, on his way for a morning swim in the Cam.
The real-life history of mathematics is strewn with such idiosyncratic individuals. Pierre de Fermat was famously reclusive, Nash disastrously schizophrenic. Kurt Gödel was convinced someone was trying to poison him and eventually succumbed to severe malnutrition, while Alan Turing died after eating an apple laced with cyanide. Small wonder then that we find these characters compelling, or that novelists have repeatedly turned to them for inspiration.
Robert Harris's thriller, Enigma, and the movie of the same name, are loosely based on Turing, while physicist and astronomer Janna Levin's 2006 novel, A Madman Dreams of Turing Machines, is a literary exploration of the lives and ideas of Turing and Gödel.
It's not just novelists who find food for thought in the field of mathematics. Psychologists who subscribe to the "extreme male brain" theory are suggesting that a talent for mathematics often goes hand in hand with a high level of emotional reserve - that it can even be a form of high- functioning autism. According to this theory, the world is divided into empathisers and systemisers. Empathisers try to figure out how people are feeling and treat them accordingly: systemisers are more interested in the drive to analyse and control.
Mathematics, with its tidy patterns and remorseless logic, appears to offer the ideal escape for systemisers. However, even mathematicians have to live in the real world and The Indian Clerk ventures into the earthquake zone where system and empathy crash into each other. In the novel, Hardy is breathtakingly indifferent to the physical and mental well-being of his young Indian protege, adrift in a strange culture and, as a vegetarian in England during the first World War when vegetables were virtually non-existent, half-starved to boot.
The debonair Littlewood, meanwhile, is overtaken by emotion when his carefully controlled "arrangement" with another man's wife blows up in his face, turning his well-ordered bachelor's life upside down in the process.
Such dramas have, of course, always been the raw material of fiction. But Leavitt's book also manages to convey the intellectual excitement of pure mathematics - and even to get a grip on some of its notoriously intangible concerns. At one point, Hardy tries to explain one of the knottiest problems in pure mathematics, the Riemann Hypothesis, to a group of schoolgirls. They gaze at him and chew their hair, clearly unimpressed by the spectacle of the extreme male brain in action.
They are, of course, us. No matter how much mathematicians bang on about the beauty and elegance of their equations, there's still a great gulf between pure mathematics and the rest of humanity; male and female, empathisers and sympathisers alike. And it may be up to art - to books, movies and even the wackier outposts of pop culture - to bridge the gap.
Who would have guessed, for instance, that maths would make huge inroads on the internet? Yet maths enthusiasts are using ever more sophisticated graphics to offer easy access to concepts that would once have been off the end of the conceptual scale. Type "mathematics and art" into Google, and you'll be directed to, among many other sites, a short YouTube video which uses fractals and random patterning to startlingly beautiful effect.
There's no telling where our cultural love affair with mathematics will lead. Maybe it's just a passing fad. But it's worth betting that within a generation even the most average 11-year-old will - with relative ease - be able to grasp mathematical concepts way, way more complex than bunches of bananas.
In the meantime, there's good news for the rest of us. If we can't understand maths, we can at least lie back and enjoy it.
The Indian Clerk, by David Leavitt, is published by Bloomsbury, £16.99
Great conundrums: never mind the answer, learn the bluff
Pure mathematics isn't always just about puzzles, it sometimes plugs into the real world. John Nash's investigations into social patterns and game theory became the foundation for the kind of analytical economics which get an airing every time there's a blip on the stock market. Alan Turing's obsessive code-crunching helped the Allies to score a decisive intelligence victory during the second World War and it also produced the invention none of us could live without: the computer.
At its purest, however, maths offers an array of celebrated problems and here, for the mathematically challenged, is a bluffer's guide to three of them.
Fermat's Last Theorem used to be the most famous unsolved puzzle in mathematics. Since 1995, when Andrew Wiles figured it out, it has become the most famous solved problem in mathematics. If anybody asks, just say: "Oh, that old thing - we're sooooo over integers."
The Goldbach Conjecture states that any even number greater than two can be expressed as the sum of two primes. Phew, that wasn't too difficult, was it? However, it's still one of the oldest unsolved problems on the mathematical books. It was posed by the Prussian mathematician, Christian Goldbach, in 1742; in 2000, British publisher Tony Faber offered $1 million to anyone who could solve it. The prize has never been claimed.
The Riemann Hypothesis, formulated by Bernhard Riemann in 1859, is the problem to which GH Hardy devotes his waking - and, sometimes, sleeping - hours in The Indian Clerk. It has to do with non-trivial zeros and the zeta function line, and may never be solved until somebody invents pocket-sized quantum computers.
Or, as one of Leavitt's characters puts it: "You're not supposed to get it. It's a paradox. All of mathematics is built on paradoxes. That's the biggest paradox of all - all of this orderliness and at the heart, impossibility."