## Al-Khwarizmi’s algorithms and the Brahmagupta connection

Jaspreet BindraThe present-day province of Khwãrezm sits along the borders of modern-day Turkmenistan and Uzbekistan, bordered by the shrinking Aral Sea, and fed by the plentiful waters of the Amu Dariya river. A thousand years ago, this land had a very famous resident, Abu Abdullah Muhammad ibn Musa Al-Khwarizmi, a scholar, mathematician and astronomer of repute. His first seminal contribution was to the science of ‘al jabr’ or the ‘reunion of broken parts’, which became Algebra. While that itself was enough to make him immortal, it was the Latinization of his name ‘al-Khwarizmi’, or ‘the native of Khwãrezm’ which gave us the 18th century ‘algoritmi’, which eventually became the word Algorithm.

If I were to pick one word which people use regularly, nod knowledgably when it is used, but do not have the faintest idea of what it means, it will be this one! Everything around us – traffic, maps, information, news, social networks, weather forecasting, shopping – seems to be governed by the all-powerful, yet mysterious, algorithms. Like many things in science, algorithms are very simple conceptually, but the magic lies in how elegantly and appropriately they are used. An algorithm is nothing but ‘a set of instructions designed to perform a specific task, based on conducting a sequence of specific actions.’

Algorithms have been around for even longer than Al Khwarezmi. In 300 BC, Euclid created the famous Euclid Algorithm, which gives a set of instructions to find the greatest common divisor of two numbers. Eratosthenes developed his Sieve of Eratosthenes in 200BC, Lui Hui in China developed one for Gaussian eliminations around the same time, and three centuries later Brahmagupta started building Chakravala, a cyclic algorithm to solve indeterminate quadratic equations.

But it is with computing and their massive processing power that algorithms have come into their own. They still continue to have interesting names – the Gift-wrapping Algorithm, the Shoelace Formula, the Mersene Twister, even Pollard’s Kangaroo Algorithm – and they do very interesting things. But, perhaps the best known and the most powerful algorithm today is PageRank, named after Google co-founder Larry Page, which basically ranks search results, and therefore decides the fate of millions of individuals companies across the planet (Incidentally, one of the earlier versions of PageRank was Backrub, which is a far more interesting name). Google tweaks its algorithm around 500 times a year; earlier they used to do large drastic changes, it was called the Google Dance and it sent marketers around the world in a tizzy. The highly accurate Google Maps algorithm which tells you the amount of traffic in your route is very interesting – not only does it crunch massive time series, hyperlocal data, it also takes into account the number and density of Android phones on the road which keep on communicating their presence, and their speed of progress, back to the giant Google cloud! Now you know why Apple’s maps are not as effective here, they do not have enough phones on the road…

Algorithms are used for myriad tasks and are replacing human beings in many of them. Machine Learning (ML) and AI are basically composed of algorithms and data. Using Natural Language Processing, they are now reading millions of resume’s and reportedly taking unbiased, rational decisions on which candidates to shortlist or hire. They are ‘manning’ retail cash registers, using spreadsheets far more effectively and efficiently, predicting weather more accurately, helping us harvest grapes at the right time to make the best wine, and driving our self-driving cars. It seems that there is no task that cannot be handed over to algorithms, as they also start writing the kind of music we would want to hear, and even replace reporters by collecting and writing news.

However, it is this very efficient black-box nature of algorithms which is now causing alarm bells to ring. If a candidate is rejected by an algorithm, for instance, how do you explain to the candidate why she was rejected, other than the fact that ‘the algorithm did it’? The police are using algorithms to screen for possible criminals, but how to explain the preponderance of a certain demographic or race in those? In her 2016 cautionary best-seller, “Weapons of Math Destruction,” Cathy O’Neil tells the story of Sarah Wysocki, a brilliant successful teacher, whose entire career was undone by biases in the algorithms which tested the students. Therefore, one of the biggest problems confronting algorithms and AI is to make it ‘explainable’ and to not have ‘biased’ algorithms. All algorithms, since al-Khwãrezm, have been written by human beings, and so how do we unsure that the failings of their creators do not creep into their creations? This becomes more important as algorithms become more powerful, and take over larger swathes of our life. However, it is heartening that explainable AI has become the biggest focus of most of the world’s largest technology organisations.

In the light of recent religious and political events, it is instructive to again go back to al-Khwarizmi. He lived and flourished in currently war-torn Baghdad, the centre of world’s learning then. His first and most famous book gave rise to Algebra, but one of this other books title was translated in Latin as Algoritm de numero Indorum, which would roughly translate as ‘Al-Khwarizmi on the Hindu Art of Reckoning’. He did not create his greatest creations alone – in a lot of his work, he built on the work of Brahmagupta, the great Indian mathematician, and made it into what runs the world today – Algorithms.

(This article was published in Mint on Nov 14 2019)