Although the early history of magic squares in Persia and Arabia is not known, it has been suggested that they were known in pre-Islamic times. It is clear, however, that the study of magic squares was common in medieval Islam, and it was thought to have begun after the introduction of chess into the region. The first dateable appearance of magic square of order 3 occur in Jābir ibn Hayyān's (fl. c. 721 – c. 815) "Kitab al-mawazin al-Saghir" (The Small Book of Balances) where the magic square and its related numerology is associated with alchemy. While it is known that treatises on magic squares were written in the 9th century, the earliest extant treaties we have date from the 10th-century: one by Abu'l-Wafa al-Buzjani () and another by Ali b. Ahmad al-Antaki (). These early treatise were purely mathematical, and the Arabic designation for magic squares used is "wafq al-a'dad", which translates as "harmonious disposition of the numbers". By the end of 10th century, the two treatises by Buzjani and Antaki makes it clear that the Middle Eastern mathematicians had understood how to construct bordered squares of any order as well as simple magic squares of small orders ("n" ≤ 6) which were used to make composite magic squares. A specimen of magic squares of orders 3 to 9 devised by Middle Eastern mathematicians appear in an encyclopedia from Baghdad , the Rasa'il Ikhwan al-Safa (the Encyclopedia of the Brethren of Purity). The squares of order 3 to 7 from Rasa'il are given below: