Sunday, November 30, 2008

a = a + b; b = a - b; a = a - b;

“Macha the dal in the microwave is done. The palak in the bowl on the table seems thawed enough, most of the ice has melted. Take a third bowl, put the dal in it, put the palak in the microwave bowl, and set it for 3 min.”

“Cha, if we could XOR swap the dal and palak we wouldn't need a third bowl da.”

As Charles ‘Peanuts’ Schulz said, "Happiness is a warm Nai." (and a hungry Nikhil and TS).

The title is the poor man’s swap program. It interchanges the values of ‘a’ and ‘b’ without using a third variable. The XOR swap does exactly the same thing, but the incisively analytical reader would of course prefer the XOR swap because it sounds cooler :-)


Wednesday, November 19, 2008

From Paduvarahalli to Palo Alto

Hello! It's been a while, so long that the very ground beneath our feet seems to have moved on. I once again take refuge in a disorganized cud of ruminations, and hope you'll think I'm too cool for a well thought-out structure.


If was asked to define one word that ruled life here, I'd choose trust. You're trusted to be honest on an assignment. You're trusted to hold yourself from taking a peek from your neighbor's paper. You're trusted to be up-to-date with what's happening in class. And as a friend of mine very succinctly remarked, Trust is a sharper whip than Regulation. While all that makes life calm, nice, fair and all that, it also makes it hair-raisingly boring. No longer do profs devise devious schemes to ensure people attend class, and stay in class and not go escape out the back door. No longer do dispassionate students take a screenshot of the desktop in the class computer, set that as the wallpaper, and hide all icons and the start menu with the selfless aim of having the prof relish the joy of a rock-steady desktop. No Good Samaritans to help the prof improve his mental skills by inverting the desktop. No longer do students need to activate cross-departmental spy networks to steal the BT101 PPTs. No more keyloggers or late-night heists of MMM's slides.

No more do resourceful young men have the grave responsibility of regretfully ending the rapture of a Mantech class by ringing a cycle bell. No longer do students with a bent for experiment write 'Amitabh Bachchan' on attendance sheets passed in class as a necessary and sufficient test to determine if the prof/TA merely counts names or reads them (and consequently, no more opportunities for profs to flamboyantly scratch their invisible beards and claim they are Gabbar Singh). If such a plague of preparedness (for exams) had struck back home, gentle reader, even the ever-dependable Ganga gumbal wouldn't have been able to finger out Savitha Bhabhi the night before Rocket Ramamurthi's exam from the depths of being just another corny sex comic, and single-handfist-edly raise it to the status of Art that defin(l)ed our Age. Can you imagine the horror of how much humanity would have missed? Can you?


There is a new social phenomenon here at Wal-mart, something I've never heard of from any of my friends in the Midwest (praised be its petite babes and even more petite rents). There you are, keeping your peace and shopping like any normal person, and just like any normal person, deeply contemplating on which brand of electronic mirror washing machine lubrication oil thinner will bring you Happiness. And suddenly!! The hairs on the back of your neck start to prick! Alert! Danger! But everything seems all right, just another aisle of dog tail flea neutering booster allergy relieving cream solvents [1]. And then it pricks again!! Harder this time! OMG! OMGWTFLOLBBQ!!!!11!!oneone!-exp(i*pi)!! even! You suddenly notice that that a dreaded Desi Networker (Dementors are to Desi networkers as Karan Johar movies are to Ekkkta KѬç極خkapoor serials: Both suck all happiness out of your life. One will ravage you and pass on, but the other is an eternal curse upon humankind) following you through all the aisles! Alert! Help! Man the lifeboats! Women and children first! ...---... ! ...---...!@#$%^&*() even! But you can't do anything! You're trapped like a mouse! A mouse in a formerly-pondy-playing-but-now-not-responding MPlayer fullscreen window in CAD lab when Raja Rao is coming your way!

He smoothly walks over to the aisle you are in, and starts looking at the same product as you. You've been smiling and making eye contact with firangs for the past few weeks now (in n00b hopes that you will one day puts with a firang chick, with Eyes As Blue As The Fairy Flax And Her Cheeks Like The Dawn Of Day. And Her, let's not get naughty here.) , and your powers of making people seem invisible, so masterfully honed back home, are weak. So you make eye contact. Poof! Abracadabra! Hocus Pocus! Off starts a delicate socio-economic analysis of 'how these people are giving so less price for so high quality product no?' [in the background, some operator's kept her finger on the PA system switch, and you hear an angry customer say that his microwave turntable didn't even live to swing a full rotation before it smoked], but he goes on and doesn't stop till he's collected your phone number, email, home address, salary, social security number, marriage plans and horoscopes, bank account numbers, spare Will signatures, 401(k) withdrawal permissions, etc. It is, of course, implicit that he will collect-call you at least 40 times every week to offer you unbeatable job offers, best stock picks, finest restaurant discounts, marriage brokerage services and give-when-you-live organ donation collection drives. You, surely, welcome all this with a light heart and a lighter purse for you are but two homesick brothers in a harsh cold faraway land. Which kind of treasonous deshdrohi spurns an opportunity to exchange sensitive personal information with newly-forged kin? The very thought!


There was a heinous aspersion cast upon the spotless singledom of my roommate and I by some notorious anti-social elements. The enormity ran thus:

Have I told you that the NRI undergrad chicks are superhot? Well they are. And it is not just here, all around. Was speaking to KVM the other day and even he agrees ( apparently Nikhil and KVM and all are trying for some hot NRI chick in [place blanked out to prevent unnecessary extra competition] ).

Tell me, gentle reader, what is a steadfastly solo man to do when his dedication to being the One is thus basely attacked? Why, compose a harangue in a language that won't jeopardise further efforts to hit on the girl, of course! So I beg to humbly submit for your kind perusal this BTP thesis which is 29 weeks past its deadline DANG wrong window this reply I wrote to a friend of mine in a chat. It's in pure Kannada, and I truly regret that I cannot give you a wee babelfish if you do not understand that noble tongue. Please don't go away, but instead hop over to the next paragraph.

And now for this heartrending tale of woe that was the meat of my rebuttal: Namagelli guru aa bhaagya? MunDedu, ondu baareeno mukha-noo torisilla, dove gati benki haaka. Route-ella perfect-aagi ittu, 80s low budget Kannada philm tara. First naavu nam paadige mane munde osi hodita idvi. Aavaga yaavano 40-ish haida bandbittu intro kotta. 'Hello, my name is ***, my daughter is just coming to study here' and talked very nicely and all. Naavibbaru, bhale biddanalla buttige maava anta sikkapatte yarrabirri pseud haakbitvi. Nenaskondrene mai jhum annatte, ashtu sahasravarnada chitra roopisibitvi IIT bagge. Avaru aa kade side-ge hoda tatkshana we ran back home and got her complete bio [searching for her in the univ directories was an adventure by iself because of her name's spelling, but that is a tale for another day. I shouldn't disrupt the shoka rasa of this conversation with the curiosity (jignyasa?) rasa]. Anyway, we mugged everything about her, right from her pet cats' names, her favorite leaves, her opinion on trout poaching in Norway, and other vitally important foundations for a relationship. HeLabeku andare nodakku ashtenu adhvanavagiralilla... ondondu angle alli chennagidlu anta noo heLabahudeno. Irali, so ibbaru datasheet itkondu, aakashadinda dharegeLida rambhege kaayta iddare, chandanada gombe tara aavi aagbitlu, classes shuru aada tatkshana. Moor hottenu, aar hottu mane ella khidaki-gu curtains-u.. aa 'mere samnevali khidki mein' song baredavanu, be***si nanna maga, avanige ee tara aagabekittu, avaaga baritiddaneno love song-anna. Chaand ka tukda full moDadalli muchi muLigihoyitu. Naaveno adige-nalli nipuNaru, naLa-ne [of naLa-damayanti fame] tattarisi murche-hogoshtu chennagi adige ballavaru, yah-kashchit sundara-NRI-rupavati-yuvati coma-ge hogibidabeku antha enella potluck plans maadidvi. By chance enadaru nam vayyari ildiro adaa haakidre aakbutre? Fatak! antha 'En bulbul, maathaadsakkilva?' antha nam Ambreesannan dialogue-u practice madiddvi. aadre munDedu horage barolla annutte! Gollum tara navibbaru-nu 'my preciousss' andkondu Facebook stalking maadkond iddivi, ashte. Aavaga-aavaaga ketta kanasalli kaado kateri taraha Nikhil-ge kitakinalli kaanistaalante.. paapa, eshtu sarti samadhana madidino avanige. Enu madodu maga, hudukidaru obbaLu lakshanavaada, soubhaagyavati kaLe iro Hot White Chick sigolla. By chance kannige chalesha (cataract) bandu mohada mankuboodinalli muchihogi aa mODi-nalli aa tara yaaradaru kaaNisi avaLige intro kodakkehodare, avaLa hesaru "Quing Ching Da Ding" andubidtaLe.. haaLu kivi ge cataract barolve, enu madodu ?


And that, dear reader, is the story of our Second Coming. Everything's not all rosy all the time, though, and on your way back from the lab late on a cool night, beside an exquisitely crafted arch overlooking a mile-long line of delicately planted palm trees, with a huge half-risen yellow moon that makes you think just for a moment that Dreamworks' intro video is maybe not so unreal, then, all alone in every possible layer of meaning the word has, it hits you: There is life, and there is grad life. And Laplacian(life). And as men who have seen it all have sung: Long you live and high you fly, smiles you'll give and tears you'll cry, all you touch and all you see, is all your life will ever be.


[0] - The title is lifted straight from Churumuri's What is Churumuri? page, but it's not plagiarism because it's true! My ancestral home is in Paduvarahalli, a suburb of Mysore :-)

[1] - I sorely miss the existence of a formal Bahuvrihi compounding scheme in English. In all 'synthetic' languages (ex. Sanskrit, Latin, German, Greek, Italian, etc.), it's routine to form loooong words after dropping pre- and post-positions, and the meaning of the word is usually something referred to by the constituent words. For example, trinetra means 'three eyes', actually means 'the guy with three eyes'. Decoding what a huge compound means can be an intensely joyous exercise, and a large part of the literary genius of Bana's Kadambari comes from amazing 5-line-long bahuvrihi words. And you have these cute little Sanskrit jokes, which I remember Raghu relating: A surreptitious Sanskrit taunt would be 'Dasharatha-nandana-sakha-vadana' == 'Dasharatha-son-friend-face', meaning Monkey-face. Of course, the wise reader would prefer the much milder 'Abey maa ki *@%^' when he's in some parts of the world.


Tuesday, June 03, 2008

A Portrait of the Politician as a Paraprosdokian Poet

From a story on Page 5 of today's The New Indian Express, Bangalore edition (My thoughts are all Green.)

"Senior Congress leader Siddharamaiah on Tuesday called for introspection among the party leaders, following the defeat the Assembly elections in the State." (Introspection? Not a denouncement that the polls were rigged? Nor an attack on the victor's character? Surely, there must be a suggestion of a scam or scandal or fraud on the victor's part, or in the very least, wife-beaterhood? No? Illve Illva? That's interesting, read read read)

"After being felicitated at a party meeting here, he said the party was confident of bagging the simple majority "The air across the State was also in favor of the Congress. Bit the party had to be content with only 80 seats" he said. "Though the party won fewer seats than the BJP, the voting per cent was in favor of the Congress" he added. (Eh? How could that be? Glory be, is he hinting at something like Parrondo's paradox, where you make a big win by making small losses, moving ahead by seemingly taking steps backward? [1] Maybe a particular form of the Condorcet election method? Shiver me timbers, verily, he is a Statesman! Pluto was a planet the last time a politician sent me scurrying to Wikipedia to understand his deep intent! What more has this sagacious seer to say? Go on, go on, go on.)

"Maintaining that the Congress will make no efforts to destabilize the government,

(Mummy! Somebody hold me, please! Could anyone have imagined something of such wisdom and forethought coming from a politician's tongue? Hark, unbelievers, Rama-raajya is nigh! Udayavaagali namma cheluva kannada naadu! Behold the golden age of polity, the transformation of the Opposition into the ever-vigilant watchdog of Democracy from the rabid mongrel that it has been so far, a reign of Justice, Truth and Liberty paralleled only, if at all, by the reigns of the icons of the Raghuvamsha, (exhale, exhale, wipe tears of joy) what more does this doyen of Dharma have to say?)

He said that the BJP-led government would fall on its own."



[0] - A paraprosdokian is a fine little thing that, well, is the reason why Groucho Marx so funny. It's a figure of speech in which the later part of a sentence is so completely unexpected that you need to read the whole sentence all over again. My favorite, told by SK, which I added to WP sometime ago: "Generally speaking, women are." And the ever dependable Winston Churchill, commenting on an adversary: "A modest man, who has much to be modest about." And in case you really have time, this one by Groucho Marx.

[1] - Did you see the moonwalking bear?


Monday, April 14, 2008

A watched pot never boils. Let's smoke it.

Here's a very nice article on Wimpy's blog on how oversampling (essentially, taking inputs too frequently) is the root cause of all misery of mankind.

I get the feeling this applies to far more than just portfolio tracking, to even ridiculously complicated and indecipherable (to me, and quite a few others) things like relationships.


Saturday, March 22, 2008


Some Prof to Nikhil (who has the superhuman ability of finding fascinating snippets like these, and begins conversations with profs on the phone with 'Yaentra Donga?') quoted by Makam (The Phenomenon. To be pronounced like 'Denny Crane'. Need I say more?) :

Whaaat is PhD? Apartment-Department-Adviser-Budweiser, thats all!


In other news, this little gem of a story has helped me in simply t(w)oo many occasions in life! And how! It helped me ward off the dreaded "Tell me how you are different from the rest of the people in the group!" and the even-more dreaded "Tell me about yourself." minefields in an IIM-B interview!! The other occasion, well, gentle reader, I am reminded of this old joke:

There are two - just two - essential ingredients to success in anything. The first: don't tell everything you know.


Saturday, March 08, 2008

Finite Simple Group (of order most excruciatingly 1)

And right when I thought it was just another dreary day spent deciding between red pills and blue pills (with not a shade of any other color :-( Life in Magenta sucks), along came this wee song that had me completely in splits! It's by this band The Klein Four Group, and all the members are math grad students at Northwestern University. The song's called "Finite Simple Group (of Order Two)", and it makes for a lovely, lovely tune even if you're not interested in Group Theory in the least :-) Thanks a ton, Harshal!

And here are the lyrics:

Finite Simple Group (of Order Two)
The Klein Four Group

The path of love is never smooth
But mine's continuous for you
You're the upper bound in the chains of my heart
You're my Axiom of Choice, you know it's true

But lately our relation's not so well-defined
And I just can't function without you
I'll prove my proposition and I'm sure you'll find
We're a finite simple group of order two

I'm losing my identity
I'm getting tensor every day
And without loss of generality
I will assume that you feel the same way

Since every time I see you, you just quotient out
The faithful image that I map into
But when we're one-to-one you'll see what I'm about
'Cause we're a finite simple group of order two

Our equivalence was stable,
A principal love bundle sitting deep inside
But then you drove a wedge between our two-forms
Now everything is so complexified

When we first met, we simply-connected
My heart was open but too dense
Our system was already directed
To have a finite limit, in some sense

I'm living in the kernel of a rank-one map
From my domain, its image looks so blue,
'Cause all I see are zeroes, it's a cruel trap
But we're a finite simple group of order two

I'm not the smoothest operator in my class,
But we're a mirror pair, me and you,
So let's apply forgetful functors to the past
And be a finite simple group, a finite simple group,
Let's be a finite simple group of order two

I've proved my proposition now, as you can see,
So let's both be associative and free
And by corollary, this shows you and I to be
Purely inseparable. Q. E. D.


Friday, February 22, 2008

Pareto Pessimum

A Pareto Optimum is a cute idea in optimization theory: In simple problems, you have one or more decision variables and one objective; your task is to find out the right values for the variables so that your objective is maximized (or minimized, depends on your way of looking at it).

Life gets interesting when you have many objectives all depending on the same one or more decision variables. The wiki page describes it rather neatly:

Given a set of alternative allocations of, say, income for a set of individuals, a movement from one allocation to another that can make at least one individual better off without making any other individual worse off is called a Pareto improvement. An allocation is Pareto efficient or Pareto optimal when no further Pareto improvements can be made. This is often called a Pareto optimum.

The old Guns-vs-Butter curve in economics is a standard example.

Life gets really interesting when you're in a situation where you can't make a move without making someone worse off, and by no means could you bear that state being called any kind of 'optimum'. A Pareto 'pessimum', then ? :-(

May you live in interesting times. - Spiteful old Chinese curse

[Now who could have guessed that that quote has a riveting wiki page of its own?]

Update: 23Feb: In the intoxicating spirit of 'Why put up a new post when you can make a tenuous 5-steps-removed-connection to something already up?', here's something!

I was speaking to Popup earlier today, and every time I speak to the man I learn something mindblowingly amazing; And so it happens that there's this song called the Sunscreen Song, which is, in essence, a page of (rather sound) advice on Life. Soundness of logic was never a sexy enough reason to read advice on living Life, but this one's different: first, it has a fascinating history. Second, it was originally most irresistibly titled "Advice, like youth, probably just wasted on the young". Third, the clincher: it's hilarious! Check this out:

Remember compliments you receive. Forget the insults. If you succeed in doing this, tell me how.

What are you still doing here?! Oh ok, here's a PhDComics parody. Now go read! :-)

And while we're still wallowing in this mood most sombre, here's the most sensible and sensitive one-line wish I've ever read:

May we have the grace to accept with serenity the things that cannot be changed, courage to change the things that should be changed, and the wisdom to distinguish the one from the other.

Strong O:-)

Monday, February 18, 2008

Hayflick limit, pooh!

[Ouch, this was languishing somewhere in my drafts, and I bumped into it only now. I wrote it a long time ago and it's a bit dated. In the meanwhile, I have realized that maybe Zen philosophy contributed more to the development of human knowledge than just inspiring exotic ice-cream koans (and plain vanilla Zen koans). Maintaining a distance is what takes you closest :-(  but c'est la vie.]

You know you're getting really old when you get a mail like this:

[Mech2k4] Sunday Declared Working and Instructional Day

bhoor Jan 17 2008 10:44 PM
how bout a mass bunk dudes??

On 1/17/08, Pasha wrote:
Are we looking forward to meeting some big shot that day?
Parliamentary Personality @ IIT M !!

On Jan 17, 2008 6:10 PM, Lace wrote:
Though i wonder how these *sarkari afsars * are working on a Sunday

On Jan 17, 2008 5:55 PM, Pota wrote:
shit. i have one slot :(
but it is sad that we are still living in a country where some vetti
politicians can cause things like the work week to be altered.

and all you can do is lament that you have no classes to bunk. Till 10th, it was only the school porkis and aspiring rowdies and KDs who would dare think of such gross sedition; Our fit and proper duty, Gentlemen, was to transcribe every cough that unbearable Civics teacher condescended to, cough, and make sure we kept our forearms and palms on rough sheets when drawing constructions in Geometry, lest the much-respected Geometry Classwork Neat Copy book gets a dusty smear somewhere and (the horror!) the teacher shakes her (nearly all my math teachers were kind old ladies) head in disapproval.

After that were the ol' JEE days where mere thought of bunking would greatly multiply your expected JEE rank; All we could do was go green (ooh I love that word!) with envy at the Commerce and Arts guys who'd call forth an act of social unity as sophisticated and involved as a mass bunk with just a scrawl on the blackboard, "Mas bunk 2day da! Njoi!". We were to silently bear the not-so-mild yoke of humiliation when all our behaviour-theoretic constructs and logic ("Macha, just wait and see da, everyone will say he (or she; the gentle reader will do well to note that we're talking about the blessed Arts and Commerce streams) will bunk, nobody actually will") failed miserably, and they actually ended up bunking en masse and going to the latest movie. Oh, Us ? You want to know what we did? We very dutifully found the effective resistance between two nodes in an infinite grid of resistors. ( That, by the way, is no trivial problem. Not at all trivial,

Then we came to IIT, and it felt like a gas expanding into vacuum. As in the latter case, no work was done, and 3.5 years went away before we knew it. And before you knew it, we have no more classes to bunk. Oh dang :-(

Customary decryption of title: The Hayflick limit is related to the number of times a cell can divide before it 'dies'. As you remember from school biology, when a cell divides, the daughter cells are as good as new, so theoretically, you wouldn't expect them to stop anytime. Neither did Alexis Carrel (the inventor of surgical stitches, by the way), but this other guy Leonard Hayflick proved him wrong. Apparently, an average human cell can divide only about 52 times before it can't divide anymore.

In short, the Hayflick limit is what kills us.

The idea is also fascinating because certain kinds of cells - stem cells and cancerous cells in particular - don't seem have this limit imposed on them, and they are, in a sense, immortal. There are lots of efforts to beat the limit, the nicest-named of which is the Methuselah Mouse prize (named after a patriarch in the Bible who is said to have reached 969 years of age). The prize is for researchers who extend the lifespan of a mouse to tremendous lengths. On a related note, do watch The Man from Earth; the movie is nice, but what makes it an especially compelling watch is this little matter of principle:

(From Wikipedia, the eternal fount of all knowledge:)

The Man from Earth is a 2007 independent film written by Jerome Bixby and directed by Richard Schenkman. In what may be an unprecedented move, the producer of this film, Eric D. Wilkinson, has publicly thanked users of BitTorrent who have distributed the movie without express permission, saying that it has lifted the profile of this product far beyond the financier's expectations.



Saturday, January 26, 2008


Bliss, Pure.

All of a sudden, a certain haunted Banyan tree at IITM is the whole wide world.

As I said: Bliss, Pure.