 In 1765, d'Alembert interceded on Lagrange's behalf with Frederick of Prussia and by letter, asked him to leave Turin for a considerably more prestigious position in Berlin.He again turned down the offer, responding that

In 1766, after Euler left Berlin for Saint Petersburg, Frederick himself wrote to Lagrange expressing the wish of "the greatest king in Europe" to have "the greatest mathematician in Europe" resident at his court.Lagrange was finally persuaded and he spent the next twenty years in Prussia, where he produced a long series of papers published in the Berlin and Turin transactions, and composed his monumental work, the "Mécanique analytique".