Lagrange accepted this magnificently expressed invitation and spent the next 21 years at Berlin.
During this period he produced an extraordinary series of papers on astronomy, on general dynamics, and on a variety of subjects in pure mathematics. Several of the most important of the astronomical papers were sent to Paris and obtained prizes offered by the Academy; most of the other papers—about 60 in all—were published by the Berlin Academy. During this period he wrote also his great Mécanique Analytique, one of the most beautiful of all mathematical books, in which he developed fully the general dynamical ideas contained in the earlier paper on libration. Curiously enough he had great difficulty in finding a publisher for his masterpiece, and it only appeared in 1788 in Paris. A year earlier he had left Berlin in consequence of the death of Frederick, and accepted an invitation from Louis XVI. to join the Paris Academy. About this time, he suffered from one of the fits of melancholy with which he was periodically seized and which are generally supposed to have been due to overwork during his career at Turin. It is said that he never looked at the Mécanique Analytique for two years after its publication, and spent most of the time over chemistry and other branches of natural science as well as in non-scientific pursuits. In 1790 he was made president of the Commission appointed to draw up a new system of weights and measures, which resulted in the establishment of the metric system; and the scientific work connected with this undertaking gradually restored his interest in mathematics and astronomy. He always avoided politics, and passed through the Revolution uninjured, unlike his friend Lavoisier the great chemist and Bailly the historian of astronomy, both of whom were guillotined during the Terror. He was in fact held in great honour by the various governments which ruled France up to the time of his death; in 1793 he was specially exempted from a decree of banishment directed against all foreigners; subsequently he was made professor of mathematics, first at the École Normale (1795), and then at the École Polytechnique (1797), the last appointment being retained till his death in 1813. During this period of his life he published, in addition
20