Zhang Heng was an astronomer, mathematician, inventor, geographer, cartographer, artist, poet, statesman, and literary scholar from Nanyang, Henan, and lived during the Eastern Han Dynasty (AD 25–220) of China. After beginning his career as a minor civil servant, he eventually became Chief Astronomer, Prefect of the Majors for Official Carriages, and then Palace Attendant at the imperial court. His uncompromising stances on certain historical and calendrical issues led to Zhang being considered a controversial figure, which prevented him from becoming an official court historian. Zhang applied his extensive knowledge of mechanics and gears in several of his inventions. He invented the world's first water-powered armillary sphere, to represent astronomical observation; improved the inflow water clock by adding another tank; and invented the world's first seismometer, which discerned the cardinal direction of an earthquake 500 km (310 mi) away. Furthermore, he improved previous Chinese calculations of the formula for pi. His fu (rhapsody) and shi poetry were renowned and commented on by later Chinese writers. Zhang received many posthumous honors for his scholarship and ingenuity, and is considered a polymath by some scholars.