Tuesday, August 16, 2011

Emergence of chaos

It's been a long long time since I wrote one of these, but reading James Gleick's book Chaos got me thinking about all that is going on these days and how much you can apply it to them, albeit in an abstract manner, since I obviously lack the mathematical skills to model it accurately.

Let me start off by introducing this one equation that started a lot of it, the Logistic Difference Equation. It may sound complicated, but all it says is that x_next = alpha * x * (1-x), where x is anything you're modeling. What many scientists found was that choosing different values of alpha can lead to wildly varying behaviors, behaviors which are actually observed in diverse fields such as weather, populations, economics etc. I'll give one small example of populations, that if alpha is small, populations remain constant, or decline, but if alpha rises above a certain threshold, it can rise explosively. Now this is a very simplistic model, but it shows what "non-linearities", i.e. functions that are not a straight line, are capable of.

Why it applies in the current context is because of the attempt to control a number of highly undesirable developments happening these days. The economy is going to hell, education is starting to suffer in a number of notable countries (I know that more than most :P). As a result or otherwise, politics is becoming much more extreme. Since the USA is too easy an example, I'll take my home country, India. Currently, a notable gentleman by the name of Anna Hazare is leading a crusade to wipe out corruption from India, starting with the government. While some may applaud, and others may scoff, my interest for the time being is to see if his approach is viable or not. For a thorough critique of his methods, try reading Greatbong's blog post about it. So Anna's idea for rooting out corruption is to create a body above all others, whose members are not elected, but nominated from the notable members of society. This body, headed by a "Lokpal" would bring forth charges against officials and try them. Now, most engineers would notice the lack of feedback in the system, meaning the system would function wonderfully if we assume the members of this board to be unaffected ghosts bereft of all feeling and earthly connections, i.e. those who cannot be swayed by us common, corrupt folk. However, if an error enters the system, e.g. a corrupt person becoming a Lokpal, can have drastic consequences, since it's very hard for the system to filter out this error. Herein lies the nonlinearity and the scope for drastic and dictatorial repercussions. Like the logistic difference equation, specific values of alpha make this an amazing system, some bad ones have the possibility of making this a mistake of Nazi proportions...

The same idea applies to economics, since this idea owes much of its origins to economics. Markets, the US economy and consequently the dollar are suffering like an enemy of Chuck Norris/Rajnikant. People are quite upset about this brouhaha and want something to be done, what this something should be varies considerably from person to person. The core of the problem is, and still remains, that the US economy does not make enough money to finance the expenditures of its people. Like it or not, that's the plain simple truth, don't believe me, look at the labels on anything sold in the USA and see what percentage is actually made there. Made in the USA is a very rare label to see these days. The one thing that's held the US up is the dollar, since being the world's reserve currency, no one wants to see it depreciate, in spite of rampant injections of fresh dollars. This is one of the reasons that USA has been able to recover atleast partially from the housing bust while other like Greece have not, as borrowing is a lot easier when you can print the payments without seeming loss of value. To those who might not understand this, just imagine a supply-demand system, where the supply of any commodity becomes almost unlimited, what would happen to its price. Truth be told, smaller scale vibrations like this have happened in the world economy in the past, it's just that things could be brought back under control much easier than today, cause the world's economy was simply in much better shape. This time it's so bad, because the USA is stretching the limits of its borrowing power (again, like it or not, it's the truth, see China's reactions, they're the biggest debt provider to the USA), and its people are not yet ready to accept that their spending is beyond their means. Similar situations unfortunately exist in a lot of the developed world. So this time the nonlinearity could be brought to heel, or could spiral out of control.

Why I keep harping about this nonlinearity is cause I work on simulations, and know that like an experimental simulation code, the point where your simulation becomes unstable and explodes is usually preceded by small oscillations in either direction, i.e. the situation becomes better, then worse, then better, then even worse and so on. These oscillations increase in amplitude and at a critical point, take over the system and every bit of expected behavior is overturned. Unfortunately for us, very little is understood about such systems, yet all of nature, physics, and even human behavior is completely non-linear. We have managed so far by approximating these, since our "alpha's" have been small, but it seems like we're quickly getting to the point where these oscillations could escalate into chaos. After all, doomsday prophecies don't always have to mean that the world ends literally...

Monday, April 25, 2011

The dance of politics, faith, and EXPTIME problems

It's been a while since I last posted, cause I've been keeping busy in other things. Now that I have a deadline coming up, my natural inclinations to shirk work are rising again. This post begins with a rather frightening thing I've noticed about news coverage in USA and the amount of debating that goes on about lots of issues. It seems like everyone has an opinion about everything, and are hardly interested in any other points of view. Though I don't claim to know the subtleties of any of these issues, the lack of interest in an actual debate annoys me no end, even though I can see the reasoning and vested interests in avoiding actual debate.

Finding correct answers to anything but the most trivial questions is a hard problem. I can give a quite few reasons for this, causality, complexity of the problem (watch my new TV favorite NUMBERS for a very hand-wavy explanation of what I mean here :) ). Tracing things back to computer science, my bread and butter, "hard" problems are usually considered in a class of NP problems. These are problems to which solutions cannot be computed by any known method in time proportional to a polynomial function of the input size. In layman's terms, this is a class of problems to which computing an answer is hard, using regular computers in any sane amount of time. This is why your online transactions are safe, cause you can't factor numbers into their prime factors easily. But the interesting part in this class is that the solution can be verified in polynomial time, i.e. easily. For example, if you know a possible factorization of a number, say 20 as 2x2x5, you can check it simply by multiplying them. Now CS has only reached these problems till now.

Coming back to political debates and arguments, you'll see that even though you may find a solution by some definition, actually proving it to be a correct solution is not possible easily. In fact whether a solution exists is not know apriori. To me at least, and for life as it is, these problems are much more interesting. After a little searching, I found out that these problems are called EXPTIME algorithms. Obviously, this claim of mine is not exactly true, but what I'm trying to say is that solutions to these problems can be found and verified in exponential time, a.k.a. very long time in layman terms, but still possible. For the time being lets assume my definition of this class of problems is accurately represented by EXPTIME, but it's more likely the EXPSPACE class (look at the wiki pages for these if you're interested). My point is simply that these are the most encompassing of all problem classes I could find.

Now, even with NP problems, algorithms only attempt to produce an approximately correct solution, since an exact algorithm can only be computed once P=NP is proven. Till then, the only known algorithm for these is pure brute force. This can be understood by trying to get out of a maze by going through every possible path. Since, in reality there are means of finding out if you're going horribly wrong (like towards a waiting minotaur), you can prune your search "tree", which is the basis of most AI methods like the ones used by Chess playing computers like Deep Blue. The thing is that for finding solutions to generalized problems, knowing when a solution is correct is really hard too, so we must rely on some intuition or develop some approximation to model the problem. The real world analogue to this is faith, i.e. when something is so complex that understanding it goes beyond one's limit of knowledge, one starts to make assumptions and trust the assertions made by someone. The gap in science and religion stems from this very fact, since science keeps encroaching on religion and magic. I quite liked the explanation given in a trailer to the upcoming Thor movie, which said that his world was one where science and magic merged, as everything could be proven by science, so everything was magical yet scientific. Coming back, faith is a sanity check employed by most problem solving machines in nature, due to the inability of any mind to model anything in its entirety.

For the CS inclined and otherwise, it's important to look at this in terms of a tree. Any brute force search is visualized as going from the root of a tree to a specific leaf which is our correct answer. We must choose a branch at every decision making step. Faith is like turning a blind eye to certain branches, saying those are off limits and our desired leaf can't possibly be on one of them. The scientific method, and to an extent an actual debate, is quite the opposite, it must traverse every possible branch unless proven to be wrong. A lot of this also works from a bottom-up philosophy, by saying we want to reach this leaf, so lets make assumptions along the way down to the root to get us here. The alternate is a top-down approach, where you want to find the leaf by traversing branches. While faith will claim assumptions as it assumes the leaf to be paramount, logic tries to find the "right" leaf by finding reasons to choose each branch to be correct.

If any of that made any sense to you, it's easy to see that faith and logic can rarely agree. Thus it is so very important to understand why we're trusting something or someone. Blind faith is like going through a maze with a blindfold on, you may think you can get out with your amazing senses, but it's likely you'll hit the minotaur, and your glorious life will come to an abrupt end. Even so, a large populace will never adopt a purely logical approach because certain effects cannot be modeled by pure logic, without using probability and statistics, which as we all know, everyone hates cause you can use them to prove pretty much anything. True nirvana can only be attained by realizing that there is no "correct", there's only entropy maximization. So unless you want to expend a lot of effort to fight randomness, the only option is to mostly accept things that don't make sense, and fight your small battles against it, hoping that like a butterfly flapping its wings, your feeble pokes at randomness can actually curtail and guide it.