(Inside Science) – In 1914, an unknown Indian man boarded a ship and traveled across the world to Cambridge University in England, where he could finally follow his passion for mathematics. In the few short years between his arrival and untimely death, he filled notebooks with formulas and discovered theorems, some of which still influence the work of mathematicians and scientists today.

The new biopic, "The Man Who Knew Infinity," which opens in U.S. theaters beginning Friday, April 29, chronicles the life of Srinivasa Ramanujan. A self-taught Indian mathematician from the city then called Madras (now Chennai), Ramanujan struggled to overcome racism, poverty, and outsider status in imperial Britain during the tumultuous time of World War I. But he eventually won over the mathematical community and was the second Indian to become a Fellow of the Royal Society.

Written and directed by Matthew Brown, the film gives an authentic portrayal of how mathematicians actually work. At Cambridge, Ramanujan, began an unlikely partnership with G. H. Hardy, who quickly recognized his impressive, if untrained, mathematical abilities. Hardy later described their collaboration as "the one romantic incident in my life."

Dev Patel and Jeremy Irons play Ramanujan and Hardy, respectively. The mathematicians had to bridge many cultural divides. A steadfast atheist, Hardy persistently placed an emphasis on reason, logic, and the "pristine proofs of the Western mathematical tradition," as Robert Kanigel's 1991 biography puts it. Ramanujan, in contrast, relied on intuition and imagination, turning math into an art with his love of form and elegance. In the movie, he tells Hardy that the Hindu goddess Namagiri writes the formulas on his tongue each night.

"Mathematics used to be an individual sport, but Hardy and Ramanujan taught us how much you can accomplish with collaboration," said Princeton mathematician Manjul Bhargava. He and other mathematicians, actors, and the director spoke at a post-screening event at the San Francisco International Film Festival.

Their rare and at times fraught collaboration makes for an entertaining film. This is in spite its sprinkling in bits of math throughout, which some viewers might find daunting. For example, upon hearing about a taxi's number 1729, Ramanujan pointed out that that it's the smallest number expressible as the sum of two cubes in two different ways (1 cubed plus 12 cubed and 9 cubed plus 10 cubed).

Hardy served as both a colleague and a mentor for Ramanujan.

"One of the privileges we have as mathematicians is training young students and seeing them mature into professionals," said Ken Ono, a mathematician at Emory University in Atlanta and consultant for the movie. "You see a lot of that in this film, and it's a testament to its authenticity," he added, speaking at the film festival.

It took Brown and his own collaborators 12 years to put the movie together. He and Kanigel strove to make it as accurate as possible, even ensuring that every formula and proof on every page, piece of slate, and quoted by the characters was correct. "This movie is a dream come true for mathematicians," Bhargival said.

It is one of a few movies focused on the life of a mathematician, including "A Beautiful Mind," loosely based on John Nash, and "The Imitation Game," which tells the story of Alan Turing. After more than a decade of research by both Brown and Kanigel, the film appears to hew more closely to the historical facts than its predecessors.

In pop culture, such as in "The Big Bang Theory" television show, mathematicians and scientists are often portrayed as stereotypically strange or antisocial people. But "The Man Who Knew Infinity" strives to portray them as humans with feelings, desires, and concerns. As teachers and policymakers in the U.S. seek to encourage more and diverse students to study in science, technology, engineering and mathematics fields, such a movie could help to reduce these stereotypes.

"Genius can be found anywhere," said Brown. "It's important to encourage talent from places where we might not expect it."

In spite of the stereotypes he faced, Ramanujan has had a lasting influence. One of his last discoveries, before dying at 32 of a liver infection, was of mock modular forms, functions currently being used by physicists to study the thermodynamics of black holes.

"This is all the result of flights of fancy by a two-time college dropout," Ono said. "It's crazy."

*Editors' note: Follow this link for more information about where the film opens, and when. *

*Additional note: This story originally contained a math error, which one of our readers helpfully pointed out. We've corrected the text and we regret the error.*