Before her marriage, Sophia, as the daughter of Frederick V, Elector Palatine of the Rhine, was referred to as Sophie, Princess Palatine of the Rhine, or as Sophia of the Palatinate. The Electors of the Palatinate were the Calvinist senior branch of House of Wittelsbach, whose Catholic branch ruled the Electorate of Bavaria. On 30 September 1658, she married Ernest Augustus, Duke of Brunswick-Lüneburg, at Heidelberg, who in 1692 became the first Elector of Hanover. Ernest Augustus was a second cousin of Sophia's mother Elizabeth Stuart, Queen of Bohemia, as they were both great-grandchildren of Christian III of Denmark. Sophia became a friend and admirer of Gottfried Leibniz while he was librarian at the Court of Hanover. Their friendship lasted from 1676 until her death in 1714. This friendship resulted in a substantial correspondence, first published in the 19th century (Klopp 1973), that reveals Sophia to have been a woman of exceptional intellectual ability and curiosity. She was well-read in the works of René Descartes and Baruch Spinoza. Together with Ernest Augustus she greatly improved the Herrenhausen Palace, and she was the guiding spirit in the creation of the Herrenhausen Gardens surrounding the palace, where she died. Issue Sophia had seven children who reached adulthood: George I of Great Britain (1660–1727) Frederick Augustus (1661–1690), Imperial General Maximilian William of Brunswick-Lüneburg (1666–1726), field marshal in the Imperial Army Sophia Charlotte (1668–1705), Queen in Prussia Charles Philip of Brunswick-Lüneburg (1669–1690), colonel in the Imperial Army Christian Henry of Brunswick-Lüneburg (1671–1703) Ernest Augustus of Brunswick-Lüneburg, Duke of York and Albany (1674–1728), became prince-bishop of Osnabrück Three of her sons were killed in battle. Sophia was absent for almost a year, 1664–65, during a long holiday with Ernest Augustus in Italy. She corresponded regularly with her sons' governess and took a great interest in her sons' upbringing, even more so on her return. After Sophia's tour, she bore Ernest Augustus another four sons and a daughter. In her letters, Sophia describes her eldest son as a responsible, conscientious child who set an example to his younger brothers and sisters. Sophia was, at first, against the marriage of her son George and Sophia Dorothea of Celle, looking down on Sophia Dorothea's mother (who was not of royal birth and to whom Sophia referred as "mouse dirt mixed among the pepper") and concerned by Sophia Dorothea's legitimated status, but was eventually won over by the financial