In the last year of Einstein's work on general relativity he met with and corresponded with the German mathematician David Hilbert. Hilbert had been working on a unified field theory based on the ideas of Gustav Mie ; he derived the theory of general relativity from an elegant variational principle almost simultaneously with Einstein's discovery of the theory. The timing of the correspondence and publications has led to a number of in depth historical analyses.