Friday, June 9, 2017

The Power of the Algorithm

What is Knowledge?

Toolbelt of Knowledge: Concepts
Algorithms
Equivalence
Emergence
Math
The Anthropic Principle
Substrate-Independence
Significance


We all know what it is like to find better ways to get things done, or to be shown a better way by someone else. Usually, this is due to trial and error. We drive the same route to the grocery store every time until we are hit with a flash of inspiration, and try a different one. If it works better, we make it the new norm. If it does not work as well, we go back to the old way. This is knowledge; we are blind, flailing about in the darkness, and when something works, we repeat it. But there is a Pool of Bethesda, an elixir that gives us sight, that elevates us from mere knowledge to the heights of mind beyond knowledge, which is understanding. This elixir is the algorithm.

An algorithm is a set of exact instructions. We don't normally use algorithms when talking to each other. If you are thirsty, you might say, "would you please bring me a glass of water?" and this is enough for the other person to know what you mean. To instruct someone to bring you a glass of water with an algorithm, you would say:

Stand up, turn toward the water pitcher, take steps until you are within an arm's reach of the pitcher, grab a glass, grab the pitcher, pour water from the pitcher into the glass until the glass is 85% full, put the pitcher down, turn toward me, take steps until you are within arm's reach of me, extend the arm holding the glass toward me, let go when I have the glass securely in my hand.

This algorithm looks obnoxious. It is not clear from this example why algorithms are useful. So let's look at another one:

If the ground beneath you is slanted, accelerate in the direction of steepest descent.

This is a simple algorithm that tells a ball what to do when it is on the ground, with nothing but gravity pushing or pulling on it.

It is said that math is the language of the Universe. Mathematical equations can be solved with algorithms, even the ones whose solutions cannot be written. Algorithms are the link between the abstract, logical world of mathematics and the concrete, physical world of reality. They are the only things that computers understand, instructions for storing and loading data, and performing tasks based on the data. Even the software that recognizes voices follows algorithms to figure out which algorithm you are trying to tell it to follow.

This is where the real potential of algorithms comes into view. Imagine you have a list of numbers and you want to know which is the biggest. Consider the following algorithm:

Start by writing the first number in the list as “biggest number so far.” Look at the next number in the list. If it is bigger than the biggest number so far, replace the current biggest number so far with the new number. Repeat this for every number in the list.


When this algorithm finishes, we can be completely certain that the number in “biggest number so far” is the largest number in the list. If there were a larger number in the list, it would have replaced the one in “biggest number so far.” This is a relatively simple example, but algorithms can be applied to much more complex questions. We could easily find the largest number on a small list just by looking at it, but this algorithm will just as easily find the largest number on a list with a million entries, even though it would take a human a long time, and he or she might make a mistake. Now we start to see the awesome power of algorithms. Whereas normal human trial and error always leaves uncertainty, where improvement could lie, a properly constructed algorithm can bring you answers with absolute certainty, or as much certainty that is logically possible with the data you have so far.

Going back to the grocery store example, human guessing always leaves the possibility for a faster route to be found. But there are only a finite number of routes, so one of them must be the fastest. If you use the right algorithm, you can find it with certainty, leaving no possibility for a faster way to be found. A crude version of this algorithm might go something like this:

Given the time it takes to drive down each street and your currently known fastest time, compare the times for every possible route. If the time passes the currently known fastest time, move on to the next route. If you reach the grocery store and your time is less than the currently known fastest time, save the route as the new fastest route, and save the time as the new currently known fastest time.

After all routes have been tested, you will know the fastest route, leaving no possibility for a faster one to be found.

image credit
But reality is more complicated than that. What about traffic, or weather? Well, we can add those as parameters into an updated version of the algorithm. A parameter is something that can change, and when it does, the result of the algorithm will be different. Every time we think of something new to worry about, we can add a parameter to the algorithm to take care of it. This algorithm is also extremely inefficient. For instance, it includes routes where you just drive in loops until the time runs out. But there are ways to make the algorithm more efficient. It could say to stop if it reaches an intersection it has already been to on this route. It can backtrack when it runs out of time instead of starting completely over. Slow segments can be remembered and excluded from future iterations. Modern GPS software has advanced, streamlined algorithms that update on the fly, which is how they can tell you the best way to get across the country, and still work even if you take a wrong turn.

But there is more. Not only can algorithms tell us the best ways to do things, but they can show us how nature works as well. Everything that exists has a way that it behaves, a nature. If it sometimes acts one way and sometimes acts another way, then there must be a reason why, a more basic nature that it follows all the time, which tells it when to behave this way and when that. Sometimes a ball rolls to the left and sometimes it rolls to the right, but this can be understood by knowing it is always pulled in the most downhill direction. Sometimes it does not roll at all, but bounces or floats. But this too can be understood by knowing that it is pulled on by gravity, among other properties and interactions. Every time we think of an exception to an object’s behavior, the exception can be understood by a deeper knowledge of its nature. The most basic levels of nature, where all behaviors can be understood, are called the laws of physics.

Since everything in reality has a nature, a way that it exists, algorithms are a perfect tool for science. Given a set of assumptions, algorithms can prove a result. There are even algorithms, such as Bayes' Theorem, which show us which assumptions are most likely to be valid given the data that we have collected!

You may think that there are surely some things that algorithms don't apply to. Take human behavior, for example. Humans are notoriously unpredictable. You would imagine there is no way you could ever find an algorithm that will predict what humans will do. But humans exist, so we must have some way that we exist, some nature. And having a nature means our behavior can be understood by an algorithm, if an extremely complicated one. If you are still skeptical, then let me not only give you a logical argument, but proof—we have already found it: our DNA. DNA tells life what it will do, including millions of parameters. DNA tells our cells how to make a brain, which can adapt to all kinds of circumstances. Everything you could ever possibly do is allowed by your DNA.

Algorithms, sets of detailed and precise instructions, can bring us to another level of understanding. When properly constructed, they can show us the best ways to do things and what is most likely to be true with mathematical certainty. They are the Universe’s gift bestowed upon us mortals, so that we may understand the reality we find ourselves in. Though we may still need to use trial and error to find the correct algorithms to use, once we have them they validate themselves. As I sit here at my computer, I marvel at the circuits and switches that make it possible for the taps of my fingers to produce letters on the screen—proof of algorithms’ power. As a scientist and a scholar, I owe most of what I know to these abstract formulaic methods. What wonderful things.

No comments:

Post a Comment