University of Königsberg
Hagen was born in Königsberg, East Prussia (Kaliningrad, Russia) to Friedrich Ludwig Hagen and Helene Charlotte Albertine Hagen. His father was a government official and his mother was the daughter of Christian Reccard, professor of Theology at University of Königsberg, consistorial councillor and astronomer. He showed promise in mathematics in high school and he went on to study at the University of Königsberg where his uncle, Karl Gottfried Hagen was professor of physics and chemistry.