The year 1913 marked the beginning of an extraordinary relationship between an impoverished Indian clerk and a Cambridge don. A century later, their remarkable friendship has left its mark in the strangest of places, namely in Futurama, the animated series from The Simpsons creator Matt Groening and physics graduate David X Cohen.
GH Hardy (1877-1947) and Srinivasa Ramanujan (1887-1920) were the archetypal odd couple. Hardy, whose parents were both teachers, grew up in a middle-class home in Surrey, England. At the age of two he was writing numbers that reached into the millions, so it was no surprise that he eventually read mathematics at Trinity College, Cambridge, where he joined an elite secret society known as the Cambridge Apostles.
Ramanujan was born in the Indian state of Tamil Nadu. At the age of two he survived a bout of smallpox, but his three younger siblings were less fortunate, each one dying in infancy. Although he was enrolled in a local school, Ramanujan's most valuable education was thanks to a library book, A Synopsis of Elementary Results in Pure Mathematics by GS Carr, which contained thousands of theorems. He investigated these theorems one by one, relying on a chalk and slate for calculations, using his roughened elbows as erasers.
Aged 21, he married Janakiammal, who was just 10 years old. Unable to afford college fees and needing to support his wife, Ramanujan got a job as a clerk. Nevertheless, he continued his interest in mathematics in his spare time, developing novel ideas and proving fresh theorems.
Curious about the value of his research, Ramanujan began to write to mathematicians in England in the hope that someone would mentor him, or at least give him feedback. Academics such as MJM Hill, HF Baker and EW Hobson largely ignored Ramanujan's pleas for help, but Hardy was mesmerised by the two packages he received in 1913, which contained a total of 120 theorems.
Hardy's reaction veered between "fraud" and so brilliant that it was "scarcely possible to believe". In the end, he concluded that the theorems "must be true, because, if they were not true, no-one would have the imagination to invent them".
The British professor made arrangements for the young Indian, still only 26, to visit Cambridge. Hardy took great pride in being the man who had rescued such raw talent and would later call it "the one romantic incident in my life".
The resulting partnership gave rise to discoveries in several areas of mathematics and Ramanujan's genius was recognised in 1918 when he was elected as a fellow of the Royal Society.
The young Indian savant would later say that many of his theorems were whispered to him in his sleep by Namagiri, an avatar of the Hindu goddess Lakshmi: "While asleep, I had an unusual experience. There was a red screen formed by flowing blood, as it were. I was observing it. Suddenly a hand began to write on the screen. I became all attention. That hand wrote a number of elliptic integrals. They stuck to my mind. As soon as I woke up, I committed them to writing."
Ramanujan's career was brilliant, but ended prematurely when he began to suffer from tuberculosis. He returned to India in 1919 and died the following year, aged 32.
However, the life of Ramanujan continues to fascinate modern mathematicians, including Dr Ken Keeler, who swapped his job as a researcher to join the writing team behind the science fiction sitcom Futurama.
He is actually one of a number of mathematicians who write for The Simpsons and its sister series Futurama. They have retained their love for the subject and they continue to express their passion for numbers by smuggling mathematical references into both series.
For example, in order to pay homage to Ramanujan, Keeler has repeatedly inserted 1,729 into Futurama, because this particular number cropped up in a famous conversation between Hardy and Ramanujan.
According to Hardy, he visited Ramanujan in a nursing home in 1918: "I remember once going to see him when he was lying ill at Putney. I had ridden in taxi cab number 1729 and remarked that the number seemed to me rather a dull one and that I hoped it was not an unfavourable omen. 'No,' he replied. 'It is a very interesting number. It is the smallest number expressible as the sum of two cubes in two different ways.'"
Their exchange can be unpacked and expressed as follows:
1,729 = 1³ + 12³ = 9³ + 10³
It is rare that a number can be split into two positive cubes, and even rarer that it can be split into two positive cubes in two different ways, and 1,729 is the smallest number that exhibits this property.
It is in recognition of Ramanujan's comment that Bender, Futurama's cantankerous robot, has the unit number 1729.
The number also appears in an episode titled "The Farnsworth Parabox". The plot involves Futurama characters hopping between multiple universes, and one of them is labelled "Universe 1729".
Moreover, the starship Nimbus has the hull registration number BP-1729.
This has certainly helped keep Ramanujan's memory alive, but it is probably not the sort of immortality that Hardy had in mind when he wrote: "Archimedes will be remembered when Aeschylus is forgotten, because languages die and mathematical ideas do not. Immortality may be a silly word, but probably a mathematician has the best chance of whatever it may mean."
Keeler is proud of his mathematical references in Futurama, and he is philosophical about the many years he spent as a mathematician before becoming a comedy writer: "Everything that happens to us has some effect on us, and I do suppose that the time I spent in grad school made me a better writer. I certainly don't regret it.
"For example, I chose Bender's serial number to be 1,729 and I think that reference alone completely justifies my doctorate.
"I don't know if my thesis advisor sees it that way though."
Simon Singh answered readers' questions on Twitter using #AskSimonSingh.
Q: What is the second highest number after 1729 and do these numbers have a name?
A: Mathematicians tend to focus on what is the smallest number that is the sum of 2 cubes in 3, 4, 5… ways. So 87539319 is smallest number that is the sum of 2 cubes in 3 ways. In "Bender's Big Score" Fry takes cab #87539319.
Q: Can you write about Kaprekar's constant 6174 sometime? I think it's better than 1729!
A: Not enough space to explain Kaprekar's constant, but I mention Harshad numbers in my book - Kaprekar invented (?) these too.
Q: Why does mathematics scare such a large proportion of the public?
A: I have a three-year-old son and can see that counting is not a natural process. Maybe the surprise that anybody ever gets maths?
Q: I wouldn't say it is rare for a number to be a sum of two cubes, there are infinitely many such numbers.
A: Fair point.
Q: What is the next big conjecture to be proven? The Riemann Hypothesis?
A: Mathematicians seem to rate The Riemann Hypothesis highly. Not something I would ever write about, as it's too complex for my writing talents.
Q: What's the next number after 1729 for positive cubes?
A: Not sure, but (as you hint) we can look at (-)ve cubes too. Bender's serial number is 2716057, which is 952³ + (-951)³.
Q: I see that #AskSimonSingh is due to take place at 16:30BST. Could you reschedule it for 17:29BST? :)
A: This is a very good idea. But it is 17.29 somewhere.
Q: I don't have a question. I just want to say I really like you as a human being
A: Thanks. I guess that is as opposed to liking me as an alien or an amoeba?
Q: Why is the number 1,729 hidden in Futurama episodes?
A: Many of the writers were mathematicians, and still love numbers, so this is their way of expressing that love.
Q: Without computers, how was Ramanujan able to compute properties like the 1729?
A: In a way 1729 spot was not miraculous. Many may know that 12³=1728, or 9³=729. Rest is easy. Except it seems that Ramanujan could do this over and over again. Every number was his personal friend.
Simon Singh is the author of The Simpsons and Their Mathematical Secrets.