The Mathematics of Mecca

How advanced mathematics were used for Islamic religious purposes in the Middle Ages

Diagram of the geometrical method of determining the qibla. From an eighteenth century Ottoman Turkish copy of the sharḥ al-mulakhkhaṣ fī al-hayʾa ("Commentary on the Compendium on Astronomy by Mahmud al-Jaghmini"), the National Library of Israel collections

In the middle of the Grand Mosque in Mecca sits the Ka‘ba, the black-covered, square edifice that is the most sacred site in Islam. While the Ka‘ba predates the Prophet Muhammad’s revelation of the religion in the seventh century—the tradition ascribes its construction to Abraham or even Adam—it is a central symbol and a focal point of worship for Muslims around the world. This is no more apparent than during the annual hajj pilgrimage to Mecca, when millions of believers gather in the holy city. The vast courtyard of the Grand Mosque fills with white-clad pilgrims performing tawaf, the counter-clockwise circumambulation of the House of God.

However, the Ka‘ba is central to prayer throughout the year, not only during the hajj: just as Jews face Jerusalem during their worship, the Ka‘ba marks the direction of Muslim prayer, the qibla. In fact, Jews and Muslims do not only share the idea of orienting prayer in general, but Jerusalem in particular. Before the Prophet Muhammad declared Mecca to be the direction of prayer, the early Muslim community prayed towards Jerusalem, and the city has retained its sanctity as the third-holiest site after Mecca and Medina.

Early 18th-century European map of the Grand Mosque in Mecca, including the Ka’ba, the Eran Laor Cartographic Collection at the National Library of Israel

The qibla is built into the architecture of mosques, which include a niche, called the mihrab, in the wall facing Mecca. When praying at home or outside, individual worshipers must determine the qibla for themselves.

Today, finding the direction of the Ka‘ba from any location on the globe is a relatively easy affair: qibla compasses built into prayer rugs, smartphone apps, and Youtube guides can point the way.

But before modernity, finding the qibla was no easy matter, and precise determinations demanded serious mathematical skills.

Photograph of the mihrab prayer niche in the Khalid ibn al-Walid Mosque in Homs, Syria, taken in 1938 by A. Reid. From the Lenkin Family Collection of Photography, the University of Pennsylvania Libraries

Magnetic compasses were first introduced in the Islamic world from China in the thirteenth century, and their use in locating the qibla was described in royal Yemenite astronomer Al-Ashraf Umar ibn Yusuf’s  (d. 1296) On the Use of the Compass Bowl (tasa) for the Determination of the Qibla, written around 1290. The text describes the making of a compass using a bowl filled with water and an iron needle magnetized with a lodestone. After locating the compass’s true north, ibn Yusuf instructs readers to count twenty-seven degrees along the rim of the compass eastward; this is the qibla for the central Yemenite cities of Aden, Ta‘izz and Zabid. As Yusuf writes:

Pray in that direction, because, when the north line is known, you know the qibla of every locality of the climates according to (its) deviation and according to all the surrounding degrees on the circle of the entire rim of the bowl that are associated with it.

Geometrical models for determining the qibla also abounded. Numerous works of scientific astronomy, which build on and refine the work of the Hellenistic astronomer Ptolemy (c. 100-170 CE), whose writings were first translated to Arabic in the eighth century, also contain a chapter on determining the finding the azimuth of Mecca from a given locale. Rather than an extraneous, religious curiosity, qibla calculation was a standard topic in Islamic science.

European map of the Arabian Peninsula, including an inset drawing of the Ka’ba and the Grand Mosque in Mecca, the 1750s, the Eran Laor Cartographic Collection at the National Library of Israel

An example of such a geometrical model can be found in a manuscript from the National Library of Israel’s collection, written around the same time as Ibn Yusuf’s work. Composed by Ottoman astronomer Qadizade al-Rumi (1364-1346), the book is a commentary on Mahmud al-Jaghmini’s early thirteenth century Compendium on Astronomy (mulakhkhas fi al-hay’a), which amassed over sixty commentaries and translations into Persian, Turkish, and Hebrew. The Mulakhkhas, one of the most successful astronomical textbooks of all time, was intended as an introduction to astronomy for advanced students, conveying detailed information in a concise, consistent, and comprehensive way.

Jaghmini provides instructions for locating the qibla using a sundial. Marking the points on a circle where the shadow cast by the sundial reaches just before noon and again towards evening determines the east-west line and the north-south meridian. If one knows the difference between the longitude and latitude of Mecca and one’s own location, one can then geometrically find the qibla—at least approximately.

 

Diagram of the “Indian circle” method for calculating the cardinal directions using a sundial. From an 18th-century Ottoman Turkish copy of the sharḥ al-mulakhkhaṣ fī al-hayʾa (“Commentary on the Compendium on Astronomy” by Mahmud al-Jaghmini), the National Library of Israel collections

The manuscript includes two diagrams illustrating the method for the city of Samarkand, where Jaghmini lived, a major cultural center in the Middle Ages. The first diagram shows the positions of the sun (the red circles) and of the black shadows, as well as the east-west and north-south lines.

Diagram of the geometrical method of determining the qibla. From an 18th-century Ottoman Turkish copy of the sharḥ al-mulakhkhaṣ fī al-hayʾa (“Commentary on the Compendium on Astronomy” by Mahmud al-Jaghmini), the National Library of Israel collections

The second diagram shows the actual determination of the qibla. Since Samarkand is to the northeast of Mecca, one is then to indicate the respective difference with lines parallel to the east-west line and the north-south meridian. A line segment drawn from the center to the edge of the circle through the point of intersection of the two new lines indicates the direction of prayer. The diagram also shows the direction for the region of Khwarezm, another important region located in Central Asia.