In this March 19, 2015, file photo, a page from the notebook of British mathematician and pioneer in computer science Alan Turing, the World War II code-breaking genius, is displayed in front of his portrait during an auction preview in Hong Kong. The 56-page manuscript, containing Turing's complex mathematical and computer science notations, is being sold by Bonhams in New York on Monday, April 13. (AP Photo/Kin Cheung, File)

A handwritten notebook by British World War II code-breaking genius Alan Turing, who was the subject of the 2014 Oscar-winning film "The Imitation Game," brought more than $1 million at auction on Monday.

The 56-page manuscript was written at the time the mathematician and computer science pioneer was working to break the seemingly unbreakable Enigma codes used by the Germans throughout the war. It contains his complex mathematical and computer science notations and is believed to be the only extensive Turing manuscript known to exist, Bonhams auction house said.

The sale price was $1,025,000.

"The Imitation Game," starring Benedict Cumberbatch in the role of Turing, won Best Adapted Screenplay at this year's Academy Awards.

Turing's dates from 1942, when he and his team of cryptanalysts were at Britain's World War II code and cypher school Bletchley Park. In one entry, Turing wrote about a complex calculus notation.

"The Leibniz notation I find extremely difficult to understand in spite of it having been the one I understood the best once!" he wrote. "It certainly implies that some relation between x and y has been laid down eg, y=x2+3x."

The sale also included a working German Enigma enciphering machine. The three-rotor device, manufactured for the German military in July 1944, sold for $269,000.

Turing was prosecuted for being gay at a time when it was illegal in Britain. He was convicted of indecency in 1952 and agreed to undergo hormone treatment in a bid to eliminate his homosexuality as an alternative to imprisonment.

This Jan. 22, 2015 file photo, a page from the hand-written notebook by Alan Turing, the World War II code-breaking genius depicted by Benedict Cumberbatch in the Oscar-nominated "The Imitation Game," is shown at Bonhams auction house in New York. The 56-page manuscript, containing Turing's complex mathematical and computer science notations, is being sold by Bonhams in New York on Monday, April 13. (AP Photo/Bebeto Matthews, File)

He died in 1954 of cyanide poisoning. His death was ruled a suicide although his family and friends believed it might have been accidental. The notebook was among the papers he left in his will to friend and fellow mathematician Robin Gandy.

Gandy gave the papers to The Archive Centre at King's College in Cambridge in 1977. But he kept the notebook, using its blank pages for writing down his dreams at the request of his psychiatrist.

The notebook remained in Gandy's possession until he died in 1995, and Bonhams describes his entries as highly personal.

At the beginning of his journal, Gandy writes: "It seems a suitable disguise to write in between these notes of Alan's on notation, but possibly a little sinister; a dead father figure, some of whose thoughts I most completely inherited."

Turing scholar Andrew Hodges, in a statement through Bonhams, said the notebook sheds more light on how Turing "remained committed to free-thinking work in pure mathematics."

"The Imitation Game," which also stars Keira Knightley, is based on Hodges' book "Alan Turing: The Enigma."

Bonhams said the buyer wished to remain anonymous. Part of the proceeds will be donated to charity.