Janelle Monae can now do the complicated calculations which helped NASA officials launch the first U.S. space mission after learning the math formula for her new film Hidden Figures.

The singer-turned-actress portrays real-life mathematician Mary Jackson in the historical drama, in which she stars alongside Taraji P. Henson as Katherine Johnson and Octavia Spencer as Dorothy Vaughan, about the three African-American women who worked behind the scenes to help NASA make John Glenn the first American astronaut to orbit Earth in 1962.

The Tightrope hitmaker admits she was also good with numbers, but her love of the arts drew her away from her studies - and working on Hidden Figures actually allowed her to revisit her brainiac past as she prepared for her role onscreen.

"I was actually in honours math, but with math, you have to study that, so when I got involved in the arts, I was (a) theatre student, international thespian, in a capella choir, after school Shakespearean classes... and I kinda got dusty, so I realised that that was not my career path," she explained on U.S. breakfast show Today.

"But, I had the opportunity to work with an incredible mathematician, Mr. Rudy. We filmed in Atlanta, Georgia and I wanted to learn the elliptical equation, that was one of the equations that Katherine and all of the mathematicians there used to help get our astronauts into space, so I did challenge myself to do that."

Janelle recently paid tribute to Glenn at the New York premiere of Hidden Figures, which was held days after his passing on 8 December (16), at the age of 95.

Hailing him as a "hero" for trusting Jackson, Johnson and Vaughan with his life, the star added to The Associated Press, "John Glenn was always on the right side of history. During a time when these women, because of their gender and the colour of their skin, were often times treated like second-class citizens, he extended his hand out, and he trusted women, and women of colour, with his life."