The forerunner of the modern Academy of Sciences, the Academy of Mathematics, was created in Madrid in 1582, during the reign of Philip II. It evolved from the environment of cooperation among the cosmographers, architects and civil engineers that served the monarch, and also involved prominent artillery experts and military engineers. The initiative was motivated by an interest that existed in the Spain of the late sixteenth century in promoting the teaching of mathematics with an eye to its practical applications in areas as diverse as mercantile calculation, cosmography, astrology on one hand, and the art of navigation and specific problems relating to military skills and construction techniques on the other. The idea of founding the Academy of Mathematics originated with Juan de Herrera, who was also its first director. It was founded in Lisbon in accordance with documents issued on December 25, 1582, and began functioning in October of the following year in offices of the Royal Alcazar of Madrid, and shortly afterwards in its own building nearby "at the entrance to Baldanú, in la calle del Tesoro". The same space is occupied today by the opera house, the Teatro Real. Due to extensive changes in the royal offices, in 1612 the institution moved to the home of the Marquis of Leganes, with its facade on the "wide calle of San Bernardo" where it carried out its activities until about 1630, when all the property, income and instruments of the Academy were transferred to the Imperial College. Later, with the flowering in Europe during the seventeenth century of academies in the scientific sphere, the Royal Academy of Medicine and Natural Science was founded in 1734. Soon afterwards the Marquis of Ensenada ordered Jorge Juan to divide it into independent branches, and in 1752 the Ordinance Plan for the Royal Society of Sciences of Madrid was drawn up. This project and the Academy collapsed with the fall of Ensenada in 1754 and there was no attempt to revive it until February 7, 1834: a decree for the creation of the Royal Academy of Science in Madrid, subsequently replaced by the Royal Decree for the creation of the Academy of Mathematics, Physics and Natural Sciences, on 25 February 1847. It carried out its first activities in various locations until 1897 when it arrived at its current headquarters in the calle Valverde at numbers 22 and 24.