From A Beautiful Mind to The Theory of Everything and The Man Who Knew Infinity, Hollywood loves a mathematician. So why cant it get beyond the fevered prodigy scribbling equations on windows?

In the Tina Fey sitcom Unbreakable Kimmy Schmidt, wealthy Manhattanite Jacqueline Vorhees wails to her assistant that she cant afford to get divorced. Even though shed get $1m for every year of her marriage.

I spend 100 grand a month. Ill be broke in 10 years, she wails. No, thats wrong, counters Kimmy (Ellie Kemper), who scribbles some sums with a marker on Mrs Vorheess window. So $100,000 times 12 months. Thats $1.2m a year. Divide that into $12m, and yes, youd be broke in 10 years. But if you invest some of it, assuming a 7% rate of return, using the compound interest formula, your money would almost double.

Kimmy turns round triumphantly: Mrs Voorhees, I mathed, and you can get divorced! Mrs Vorhees eyes Kimmy narrowly. Those are not, she complains, erasable markers. What she doesnt mention is that math isnt a verb. Not yet.

The scene is, among other things, Feys satire of the Hollywood cliche of genius squiggling on glass. In A Beautiful Mind (2001), for instance, Russell Crowe, playing troubled maths star John Forbes Nash Jr, writes formulae on his dorm window. This scene is echoed in The Social Network (2010), where Andrew Garfield sets out the equations for Facebooks business model on a Harvard window while Jesse Eisenbergs Mark Zuckerberg looks on. In the opening scene of Good Will Hunting (1997), janitor prodigy Matt Damon writes equations on a bathroom mirror.

Why do so many Hollywood maths whizzes forego paper? Stanford mathematician Keith Devlin explains. Depicting a mathematician scribbling formulas on a sheet of paper might be more accurate, but it certainly doesnt convey the image of a person passionately involved in mathematics, as does seeing someone write those formulas in steam on a mirror or in wax on a window, nor is it as cinematographically dramatic.

Good point. When we watch A Beautiful Mind and look through the window at our Russ, Hollywoods most built mathematician (counterexamples on postcards, please show your workings), we pass beyond incomprehensible equations and convince ourselves were seeing Genius at Work. Even if, as some critics have complained uncharitably, Russs pi glyphs, greater-than and less-than symbols and such dont make sense.

But theres another way maths movies can confound the Boredom Equation, namely by leaving a black hole where the maths should be. The Man Who Knew Infinity, the new film starring Dev Patel and Jeremy Irons about the great Indian mathematician Srinivasa Ramanujan, is intriguing in this respect. Although we see Ramanujan doing maths, mostly the film is interested in other things how he falls in love with his wife, the pain of separation when he travels from Madras to study at Cambridge, the racism he suffers in England and, most stirringly, the narrative arc from lowly clerk to globally recognised mathematician.

Russell
Hollywoods most built mathematician Russell Crowe in A Beautiful Mind. Photograph: Universal Studios

That said, the film has its charming moments. When Hardy visits Ramanujan in a nursing home, he complains about the boring number of the cab that brought him there. Ramanujan begs to differ: 1,729 is the smallest that is expressible as the sum of two cubes in two different ways. Today 1,729 is known as the Hardy-Ramanujan number. How does that work, you may be wondering? Like this: 1729 = 13 + 123 = 93 + 103.

Ramanujans mentor GH Hardy (Irons) is an atheist and rationalist, exasperated that this Indian prodigy cannot produce proofs for his work and, worse, is doubtful that proofs can explain the inexplicable. You wanted to know how I get my ideas, says Ramanujan. God speaks to me. But while the film may sketch two different mathematical philosophies, we leave the cinema with a warm glow that comes from anything but hard thinking.

If you want to learn some more about Ramanujans contribution to mathematics, rent High School Musical. Freeze-frame it at the moment brainy Gabriella Montez challenges her teacher. On the board are two of the equations of the inverse of the constant pi (1/) that Ramanujan offered in his first paper published in England. Shouldnt the second equation read 16 over pi? asks Gabriella. Of course it should.

Cinema often struggles with dramatising difficult ideas, particularly if they are abstract. One way of overcoming that problem is by metaphorical explanation. For instance, in Nicholas Roegs Insignificance (1985), a Marilyn Monroe-like character demonstrates relativity using toy trains and flashing lights. In The Theory of Everything, Jane Hawking uses a pea and a potato to explain the difference between quantum theory and general relativity, while her husbands friends explain Hawking Radiation with beers and crisps.

Movie explanations of difficult stuff, though, may obscure rather than enlighten. Whats more, some directors know this and have fun pointing out the shortcomings of their medium and those of their audiences. In Adam McKays The Big Short (2016), for instance, Margot Robbie sits in a tub sipping champagne and describing how sub-prime loans work. Her explanation is doubtless coherent, but when Im looking at a beautiful woman in a bubble bath, Im not thinking about credit default swaps. So sue me. Later in the film, chef Anthony Bourdain chops fish in his kitchen while describing how collateralised debt obligations work. Finally, Selena Gomez plays roulette to illustrate the idea of gambling on other peoples gambles.

Each scene serves as a parody of explanation. They are part of a film that mocks you, you poor jerk, and your intellectual aspirations. You are never ever going to understand how difficult stuff works from watching movies, however much youd like to.

Sometimes, though, cinema can give a real insight into the intellectual process. In Agora (2009), Rachel Weisz as ancient philosopher Hypatia does an experiment on a ship to test relative motion. If, she hypothesises, you drop a heavy sack from the mast while the ship is moving forward, it will fall on the deck several feet behind the mast. The sack is dropped and falls much closer to the mast than she predicted. Hypatia claps her hands in delight. But you were wrong! says the ships captain. Yes, but it is definitive proof! The sack behaves as if the boat were stationary.

What does that mean?

I dont know. But the same principle could be applied to the Earth. It could be moving around the sun without us realising.

Hypatia, that is to say, infers a revolutionary heliocentric cosmology from her falsified hypothesis. The film thus generously gives us what we are effectively denied in Good Will Hunting or A Beautiful Mind the inside track on how someone clever is thinking about a problem. Whats more, its an antidote to Hollywoods vision of genius. It suggests that getting stuff wrong is at least as important in the story of human intellectual progress as being right all the time.

Maths is often reduced to nothing more than a MacGuffin. In Rushmore (1998), for instance, Max Fischer (Jason Schwartzman) is reading the newspaper while his teacher tells his class that on the blackboard is the hardest geometry equation in the world. What credits would anyone solving it get, asks one student. Well, considering Ive never seen anyone get it right, including my mentor Dr Leaky at MIT, I guess if anyone here can solve that problem, Id see to it that none of you ever have to open another math book again for the rest of your lives.

Thus tempted, Fischer folds his paper and goes to the blackboard, and squiggles his solution while nonchalantly sipping espresso. The film at this point has nothing to declare but Fischers genius. Do we really believe Jason Schwartzmann can compute the area of an ellipse? Sure. Whatever.

Genius squiggling is there once again merely to help Hollywood tell the sentimental story it never tires of: namely the story of someone usually borderline demented and by definition insufficiently recognised sticking it to the establishment.

Rushmore
Genius squiggling Rushmore

None of this should suggest we cant learn maths from movies. In Tina Feys Mean Girls (2004), for example, Lindsay Lohan plays a finalist in the Illinois high school mathletes state championship. Will her North Shore High team stick it to those prep school toffs opposite? Heres the first question: Twice the larger of two numbers is three more than five times the smaller, and the sum of four times the larger and three times the smaller is 71. What are the numbers? Got it yet? 14 and 5. In the end, Lohans team become the new state champs because she wins the sudden death tie-break. What does the scene prove? That those of you who thought Lindsay Lohan cant do maths should really have a word with yourselves.

Perhaps the most resonant maths scene in Hollywood cinema, though, comes in a very old comedy. In the Abbott and Costello movie In the Navy (1941), Lou is a ships cook. Hes baked 28 doughnuts, which he reckons is just enough to give 13 to each of his seven officers. But seven goes into 28 four times, objects Lous straight man. Not so, says Lou, who goes on to prove it on the blackboard in a masterclass of cheating and illusion. The scene demonstrates a general truth, namely that when Hollywood does maths, it doesnt necessarily add up.

The Man Who Knew Infinity is released on 8 April.

Read more: http://www.theguardian.com/film/2016/apr/06/mathematics-movies-the-man-who-knew-infinity