Wednesday 7 November 2007

Law of small numbers and such...

The first strong law of small numbers (Gardner 1980, Guy 1988, Guy 1990) states "There aren't enough small numbers to meet the many demands made of them."

The second strong law of small numbers (Guy 1990) states that "When two numbers look equal, it ain't necessarily so." Guy (1988a) gives 35 examples of this statement, and 40 more in Guy (1990). For example, example 35 notes that the first few values of the interpolating polynomial (n^4-6n^3+23n^2-18n+24)/24 [...] for n==1, 2, ... are 1, 2, 4, 8, 16, .... Thus, the polynomial appears to give the powers of 2, but then continues 31, 57, 99, ... (Sloane's A000127).
I just read this at Wolfram Mathworld; and something flashed within me. What if the differences between this poly and the actual powers of two were significant? Well, being terribly bored and having a lot of time to kill, I set out to explore that. I was stuck at the first step itself - I was in Linux, and didn't know any way to do math explorations like this. Had I been in Windows, I would have used Matlab (damn good and surprisingly easy to use). I'm sure there's some 'popular' Free Software for this kind of job, but I was not in a mood to search for software packages and get into dependency hell just yet. So, I just asked myself, can I do it with what I do know to do in Linux?
Writing C programs. Perl scripts. Shell scripts. For this kind of job, Perl somehow seemed more appropriate. So, I typed out a Perl script to find the differences (here f(n) is the 4th order polynomial given in the above article):

No obvious pattern emerged. Then, on second thoughts, there did seem to be some sort of pattern to it. The differences are all increasing. But each one increased by a lesser amount than the previous one. 7/1 is (quite obviously) 7, 29/7 is slightly greater than 4, 93/29 is slightly greater than 3, etc. As the numbers increased, it seemed that they increased by successively smaller factors. The numbers had some kind of geometrical pattern - sort of like a geometric series where you get successive terms by multiplying each term by a constant ratio. However, in this case, the ratio wasn't exactly constant. Instead, it seemed to be tending towards some constant.

To check this out, I then printed the quotient obtained by dividing each difference by its predecessor. Lo and behold, suddenly, there was Light:
So, there you have it: the quotient of dividing each successive difference between 2^n and this f(n) is approaching 2. For n=70 and higher, it was so close to 2 that Perl gave it up and printed it as just 2. So, the quotients are converging towards 2 as far as we can see. Each successive difference, then, is obtained by multiplying the previous difference by a number very close to 2.
That is the kind of beauty math has. You obtain a sequence that looks like powers of 2 for small numbers, you find that it deviates from the actual value for higher powers, then you find that the deviation itself is increasing in powers of two. This thing has some inexplicable beauty to it... :)
So, now that we've found that this thing seems to converge to 2, how do we interpret it? That's the kind of thing for which you need mathematical training. If I had had some good math course on series and sequences, may be I would know what to do with this. May be I'd theoretically prove that the quotients actually converge to 2 as n tends to infinity. May be we can show that this f(n) can indeed be used to find powers of 2.
For now, let's get into the nitty gritty of this number crunching. First, I wrote this cute little program (any claims to its uncuteness are by Agents of Satan; avoid them like plague) :


use warnings;
use strict;

my @range = (6 .. 24); #6 is where the differences start to be non-zero
my $i;
my @diffs;

foreach $i (@range)
print $i,"\t\t";
print (( $i**4 - 6*$i**3 + 23*$i**2 - 18*$i + 24 ) / 24, "\t\t");
print 2**($i - 1), "\t\t";
push @diffs, (2**($i - 1) - (( $i**4 - 6*$i**3 + 23*$i**2 - 18*$i + 24 ) / 24));
print $diffs[$#diffs], "\t\t";
$#diffs && print $diffs[$#diffs]/$diffs[$#diffs-1];
print "\n";

Then, I ran the output through txt2html with --make_tables option. I got the HTML code for a table, which you can see with naked eye by right clicking here and choosing 'View source' (or whatever option reads close to that). Using the code, I made a blog post named 'Law of small numbers and such...'.

You just finished reading it!

Tuesday 28 August 2007

A Gentle Echo on Woman: LOTD
The content of the poem isn't completely right (IMHO), but the concept is great. Hats off to Swift's power of imagination and creativity.

Sunday 29 July 2007

The Best Geek Quotes, Sayings, and Phrases - 51 to 60

1. In the beginning GOD created the Bit and the Byte. And from
those he created the Word.

2. And there were two Bytes in the Word; and nothing else existed.
And God separated the One from the Zero; and he saw it was

3. And God said - Let the Data be; And so it happened.
And God said - Let the Data go to their proper places.
And he created floppy disks and hard disks and compact disks.

4. And God said - Let the computers be, so there would be a place
to put floppy disks and hard disks and compact disks.
Thus God created computers and called them hardware.

5. And there was no Software yet. But God created programs; small
and big... And told them - Go and multiply yourselves and fill
all the Memory.

6. And God said -I will create the Programmer; And the Programmer
will make new programs and govern over the computers and
programs and Data.

7. And God created the Programmer; and put him at Data Center;
And God showed the Programmer the Catalog Tree and said
You can use all the volumes and subvolumes but DO NOT USE

8. And God said - It is not Good for the programmer to be alone.
He took a bone from the Programmer's body and created a
creature that would look up at the Programmer; and admire
the Programmer; and love the things the Programmer does;
And God called the creature: the User.

9. And the Programmer and the User were left under the naked DOS
and it was Good.

10. But Bill was smarter than all the other creatures of God.
And Bill said to the User - Did God really tell you not to
run any programs ?

11. And the User answered - God told us that we can use every
program and every piece of Data but told us not to run Windows
or we will die.

12. And Bill said to the User - How can you talk about something
you did not even try. The moment you run Windows you will
become equal to God. You will be able to create anything you
like by a simple click of your mouse.

13. And the User saw that the fruits of the Windows were nicer and
easier to use. And the User saw that any knowledge was useless
- since Windows could replace it.

14. So the User installed the Windows on his computer; and said to
the Programmers that it was good.

15. And the Programmer immediately started to look for new drivers.
And God asked him - What are you looking for? And the
Programmer answered - I am looking for new drivers because I
can not find them in the DOS. And God said - Who told you need
drivers? Did you run Windows?
And the Programmer said - It was Bill who told us to !

16. And God said to Bill - Because of what you did you will be hated
by all the creatures. And the User will always be unhappy with you.
And you will always sell Windows.

17. And God said to the User - Because of what you did, the Windows
will disappoint you and eat up all your Resources; and you will
have to use lousy programs; and you will always rely on the
Programmers help.

18. And God said to the Programmer - Because you listened to the
User you will never be happy. All your programs will have errors
and you will have to fix them and fix them to the end of time.

19. And God threw them out of the Data Center and locked the door
and secured it with a password.


Thursday 19 July 2007

A cool captcha!

Are you human?
This is a question we often get asked when registering for things on the net - the sign up page gives a scrambled image containing some text, and we are asked to type out the characters from that.
This is to make sure that we are indeed human, and not some software created to make fake registrations for illicit usage. The idea is that software programs cannot 'see' the text within the image, while we humans can.
Now, this site has a cool new way of doing it: instead of asking to type out letters from an image, it asks us to solve a math problem. It is usually a simple problem which can be solved by anyone with undergrad level math practice. I got 'what is the least zero of the polynomial x^2 + 3x' (the answer is -3).
While not everyone might be able to solve these problems, the site registration too is not for everyone - it's a registration to download a 'quantum random bit generation service' client; someone downloading that can probably solve these problems hands down...

PS: No, I didn't download the client. I registered only because I heard about this cool method of doing a captcha and wanted to give it a try... :)

Google to search man pages

You are in your browser, furiously typing away your latest shell script (to send it to someone else, or to post in forums or at Slashdot). Suddenly, your memory trips you up, and you find yourself wondering "does the 'cut' command use a space or a tab as the default delimiter?". With Google at your service, there is no need to move away from your browser. If you are on firefox, just type 'man cut' in the addressbar; otherwise, google for 'man cut' and use the first result.
Google doubles up as a 'linux command helper' like this whenever we use search queries of the form 'man command'. Add one word to the query anywhere, and we get our good old Google search.
I had been using this method for quite a while. But I was not sure whether it was an intentional feature or it's just that the man pages tend to be the first results. But today, when I tried 'man cut', I landed on the man page. It is hard to imagine that a man page could overshadow common meanings of the words (man and cut). So, it does seem that google treats 'man command' searches specially...
It seems that this is not an officially announced feature - a google search for details about it returned no relevant results. Anyway, it does work. Our beloved man pages are now only a 'new tab' away!

Friday 6 July 2007

Linux is for everybody - just approach it the right way!

Linux is for everybody.
Yes, I just said that.
A few months ago, I would have vehemently opposed such a statement. That was when I was trying to learn the Linux GUI - because that's what many recommended on forums; a lot of posts said Linux with a GUI is very much like Windows.
It isn't.
Then, I did the Right Thing - I got hold of a Unix book (not a Linux book - because a lot of them try to 'simplify' the task at hand and suggest things that won't work in many situations).
If there's one good thing about the Unix books, it's that they don't try to teach you GUI. We all (well, at least most of us) come from Windows or Mac and are very much used to the GUI. So, when we learn Linux, we try to use the GUI the same way we've used it for so many years.
The problem is, it doesn't work that way. Linux does have a GUI, and it has improved a lot. However, unless you learn the command line, life's going to be pretty difficult for you...

Command line? That strange black entity with no fancy icons or anything?
Yep... But it isn't as unfriendly as you think. In fact, you'll get accustomed to using it in some 15 minutes. And you'll start loving it in a few days.

But... but.. doesn't that mean I have to learn some commands? (Gulp...)
Yes and no. You do have to learn a few basic commands, but they are really quite a few, and aren't all that difficult to learn. The other commands you can always look them up. We'll come to that shortly.

Before that, let's see a few things that are essential in making the command line easy:
* Tab completion: Type half of a filename, type a tab, and Linux completes the name for you. Type a few letters of the latest command you learnt, type a tab, and you get the command completed for you. This might not seem all that important, but this is what transforms a laborious job of typing out everything into a quick and easy way of doing things.
* Command history: Anytime you want to repeat a command, or do a slightly modified version of it, press the up arrow a few times. You can go through a long history of the commands you typed. This is the next important feature in using a CLI (Command Line Interface).
* apropos: This is a nifty little program that searches the help pages for a word you specify. Not sure what program to use to view pdf files? Do an 'apropos pdf', and you get a list of all programs whose descriptions contain the word pdf. This is the 'look it up' utility I talked about earlier...
With these three features at hand, you can master the world of Command Line in a few days. Want to shrink that to a few hours? Just keep watching here - we'll look at a few very important, easy-to-use commands that will make you a confident user of the command line, and will get you some awed looks from among your geek friends... :)

LOTD: What are you investing in? Technology, or yourself?

Monday 2 July 2007

Two laws which will ensure your product's success

1. If Metcalfe's law can apply for your product, make it insanely cheap and easy-to-use.
2. Assume Metcalfe's law will apply.

Note: The accurate versions of these laws tend to become too long and boring (I think Randall Munroe once did a cartoon on this), so please try to think up the accurate versions and then discard them... :).

Anyway, these words of wisdom originated when I was reading an article about Apple's Macintosh. The Mac seems to be a wonderful piece of work... And everyone who own's one seems to be very proud of it. But, to this day, I personally don't know anyone who owns one, or would even consider buying one.

Why is it so?

I think the above 2 laws are the answer.. PCs were cheap from the beginning. Macs were not (or at least they were perceived to be costly). So, the ordinary Joe went for a PC, and only the elite thought of the Mac. This became a sort of a rule, and the owners of the Mac actually seem to be proud of this. However, this is not good news for Apple - they lose potential customers. So, the folks at Apple seem to be trying to catch up, but I don't think they'll be terribly successful because, whatever Apple does to make Mac better,

* when geek George goes out to buy a computer, he knows that he needs a PC because every one of his friends has a PC, and he would anyway be developing applications for a PC only - that's where the market lies.

* when papa Peter goes out to buy a computer, he knows that he needs a PC - he doesn't want to be the 'odd one out', nor is he delighted by the idea of always having to make sure whether a particular software will run on a Mac before downloading it.

* when grandma Ginny goes out to buy a computer, she knows that she needs a PC - because everyone says so.

So, that quite sums it up - it all comes down to Metcalfe's law. More people use it, more people buy it, more people use it, more people buy it, and so on ad infinitum.
And that perhaps explains the ubiquity of products which are cheap, low in quality, and insanely popular. Just look around yourself, and you'll probably find one...

LOTD: Real Success Recipes

A fresh addition...

The net is full of random things. However, everyday, I happen to stumble upon something really worth sharing. And I'm going to share them with you...
So, from now on, I'll post every day a Link Of The Day (LOTD). Under unusual circumstances, I might overdo and post more than one LOTD, but I'll try to avoid that.
That's it for now... Have a wonderful life. Let you conscience lead you on your Tao.

Oops! I forgot to tell you...

...that FDMalso has a nice little feature called the drop box. Whenever FDM is loaded, a small unintrusive box (with a downward arrow on it) floats on the screen. When you see a link you would like to download using FDM, you can just drag the link and drop it in the box (hence the name 'drop box'). FDM takes over the download... This is perhaps the best feature of this download manager. But, spoiled as I have been by other download managers, I forget this box quite often and use the older 'monitoring' methods. Perhaps this post will get me started on using this neat little box.

Sunday 1 July 2007

Free Download Manager

The title is the actual name of a program. It is, well, a free download manager... (You can get it at
I had been using GetRight for a long time as my download manager. Must say it did quite a good job. But I was sticking to it not because I loved it or anything; I had just gotten used to it. Then, as I told you before, I decided not to use any pirated software. So, I downloaded the Free Download Manager. I must admit that I wasn't expecting much. After all, it's totally free, and not that popular anyway...
But FDM (that's what they call it) totally exceeded my expectations.
First thing, it is not at all intrusive. Occupying about 1% of my RAM, it just sits quietly on the system tray waiting for my command.
When I click on the system tray icon, the FDM main window pops up. The user interface of the window is good, simplistic and well thought out. Add a URL to download? Click the + button. Schedule the download? Click the clock. Intuitive? You bet!
FDM also has the clipboard monitoring and browser click monitoring facilities I've become very much used to (Note: I'm not sure if these options are enabled by default, but they are available by just right-clicking on the system tray icon).
Whenever I click a downloadable link on my browser (for eg. a zip or exe file), FDM understands I want to download the file, and pops up. The window contains the link I clicked, the place where FDM will download it, and a button to check whether the link leads to a malicious download, among other things.
However, there is one caveat: files are marked as malicious or not by people like you and me (not by security experts), so they are not always reliable. A few times, I get a false alarm that the download is malicious. So, my suggestion would be to ignore a warning if only a small percentage of users have marked it as malicious, and pay serious attention only if a majority of users warn about the download.
Sometimes, people just place the address to a download on a web page, without actually making it a clickable. FDM is intelligent enough to handle these too. Just select the address, right-click and copy. FDM springs up and asks where to save the file...
And while the file is downloading, you can just move to your browser and continue surfing the net.
On the other hand, if you choose to remain in FDM, there are quite a few things you can do.
The first tab at the bottom of the window, the log, shows textual messages about the progress of the download.
The second tab in it is one of my favourites: it shows the progress of the parts of the file. Click on the screenshot above and take look at it to see what I mean. From a utilitarian point of view, it isn't terribly useful, but it just thrills me to be able to see an exe or zip file being 'filled' by bytes from some server somewhere. :)
And if you happen to be downloading audio or video, you can preview it from within FDM itself - that is the next tab.
The last tab is the 'opinions' tab, where you get to look at the opinions of others who have downloaded this same file. In most cases, this is useful only to get a fuzzy idea of how the downloaded file is going to be; however, in some cases (especially when downloading antivirus or firewall software) these opinions give very useful info about any possible incompatibilities. This way, you know beforehand how to tackle any problems you might face.
And last but not least, FDM manages to do what I mean (DWIM) most of the time. It does not try to be over-intelligent and annoying, and yet manages a very good job of helping me out. In these days of overly bloated programs filled with unnecessarily features, stumbling across this kind of simple, yet powerful programs is becoming quite rare. Kudos to the makers of this wonderful program...

Monday 25 June 2007

Web 2.0? Where do I get it?

With everyone on earth talking about Web 2.0, I decided I needed to at least know what it meant... After some Wiki-ing and navigating around, it all comes down to this: Web 2.0 is a sort of revolution in the Internet where the websites are metamorphosing from mere content delivery tools to interactive user controlled sources of web services.
Phew, that was quite a mouthful. I'll put it in plain English now.
Back in the good ol' days of the Internet, every web page looked like this one: some (hopefully useful) content and a bunch of links. That was all there was to it... Web designing? Who are we kidding? :)
The folks at Netscape decided this was too boring, and introduced Javascript. This was a way to make the web pages lively; it made possible things like menus and other interactive elements(and, unfortunately, pop-ups too) in web pages. Slowly, websites were evolving and using more and more of Javascript and other new-fangled things like CSS.
Then, when nobody was noticing, these new stylish additives came to the forefront. Instead of being just frills and laces on the basic HTML content, they became the important parts of the web pages. Anytime you open Gmail or Google Reader, you see that the pages are entirely responsive to you. It looks more like a desktop program than a web page. That is because they use a (relatively new) technique called AJAX. These types of websites, which look more like desktop programs - which interact a lot with us and change their appearance according to our wishes and whims - are the things that make Web 2.0.
Note that it's not the technology that distinguishes these things. Of course, it is the development of new technologies that made these possible in the first place. But what is important to a Web 2.0 app* is that it is user-interactive.
To make things clearer, let's imagine a 1990's website as a shy child going back to Momma (web server) and asking what to do each time we ask a question (make a click)...
Then, a Web 2.0 app is a sociable teenager (I'll call him W2 from now), ready to converse with you and trying to respond to you by himself. He's a much more interesting person, bubbling with energy and eager to grow more and more. That's a Web 2.0 app - interactive, with lots of decision making made on your own computer (rather than at the server), and very interesting..
However, like every teenager, a W2 has his quirks too. Sometimes he thinks he knows too much, and does things you don't want to. For example, some W2 apps make the 'Back' button of the browser effectively ineffective. This is very annoying for people like me, who click a lot of things and switch back and forth between pages. Also, a growing teenager needs a lot of resources - and so does a W2 app, typically needing more memory and processing than an ordinary (good ol') HTML website. And finally, a teenager crashes and breaks a lot of things (some scientist says it's because their bones are growing too fast for the muscles) - and, sometimes, so do W2 apps. With all their dynamically changing memory requirements and all the jugglery they have to do, sometimes W2 gets too tired and dies - leaving our browser and sometimes our system too unusable..
But when all is said, he's only a teenager, and has a long way to go. Signs are that he'll grow up to be a very smart and sociable person, very much adaptable to the society around him. People say he's going to be the Hero of the Internet; let's hope he remains a user-friendly hero...

Saturday 23 June 2007

Google Talk gets better

Now, when you are talking to a friend using Google talk Gadget and think you need to start a conference, no need to switch to Yahoo messenger or anywhere else. The Google Talk gadget now has a facility to 'group chat'. Click 'Group chat', add other Gtalk friends, and chat away...
As of now, this feature is not available in the Gtalk clients we install and use from the computer. Only the web based version (the 'gadget') has this. But Google promises that the next version of the desktop based Gtalk clients will be much more advanced than it's web-based gadget. Also, only the person inviting others to Group chat needs to be using the gadget. Others can be using the gadget or the desktop Gtalk client or anything else.

Thursday 21 June 2007

Why do you like music?

    Why do you like music? I think our brain's urge for survival is the reason.
    What is there in music that attracts everyone? And what is special about some songs that everyone everywhere gets hooked to them?
    One thing that every song has is a rhythm; some amount of predictability. Human brain likes this... So, one ingredient to a good song is some amount of predictability.
    But every song (except in very rare cases) has a rhythm. What is it that makes a 'great' song? One thing I noticed was that, in a good song, there were repeated, subtle changes to this basic rhythm. These changes were scattered throughout the song. The basic rhythm contained a short syllable, but a few times, just quite a few times, the singer drags it quite long. This kind of altering makes a song more appealing.
    Predictable, having a rhythm, but having subtle variations.. Where do these strange rules for good songs arise from?
    After a few days of 'research' into this, I now have a theory of why it is so. I could call it 'Music as an Evolutionary Survivalistic Aid - an Information Theoretic analysis'. But I'd rather call it the 'better than ya, buddy' theory here.
    When we hear a song, our brain tries to store it. If there is a rhythm and predictability in the song, it (probably) makes this easy for the brain. So, that gives us the first rule.
    The second rule comes in because of our brain's desire to prove itself better than others.
    Everything in our body is optimised for survival. When you demonstrate in public that you are capable of something non-trivial, you increase the chances that the opposite sex finds you attractive; and, in the end, that your gene survives in the form of your kids. Whether we are consciously trying to get this attraction or not, our brain continuously does it. It is something wired in to our very brains, in order to assist in survival.
    Now, the second rule tells that there are near-random variations in the song's basic rhythm. This means that storing the song is non-trivial - you need to remember exactly where variations happened and what the variations were. So, as long as the variations don't get too difficult to remember, our brain likes these kind of songs. It thinks(?) that this will help us in our evolution. It's as if 'proving' that we can do this will raise our image in public. So, the brain takes extra efforts to remember these songs. Later, when the song is played when you are among friends, brain remembers and retrieves the song. As long as you sing it right, evolutionarily you are doing the right thing, so more of 'happiness chemical' is released in your brain. This, in effect, encourages you to sing the song right and makes it a 'happy' experience. And guess what? You tell everyone that you 'looove' the song. When this becomes a collective experience, the song becomes everyone's favourite.
    And in the same way, when the song becomes too popular, some of us (our brains) decide that knowing the song has become a trivial thing, and lose our interest in it. A newer song has a lot more variety and will be a lot more appealing then...
    Note: All this is just my own theory of how all this works, obtained by making interpretations of what I saw at work in my own mind. YMMV...

Tuesday 19 June 2007

My system is piracy free! :)

How would you feel if $1800 worth of software was given to you free of cost? By the company that makes them?
That's how I feel today. Months ago, I registered for Imagine Cup. I just thought it was yet another software contest. The front page talked about "valuable downloads". I didn't imagine that meant getting:
  • Microsoft Windows XP Professional with Service Pack 2
  • Microsoft Visual Studio 2005
  • Microsoft Vista Business Edition
  • Microsoft Office 2007 Standard
free of cost. Free to download, install and use. Given by Microsoft themselves.
May be you are skeptical; Asking me 'Where's the catch?'. It seems there's none. May be they believe they can get a few of us buy future versions of Microsoft software by this. May be they don't want us to surrender to the Linux World Domination efforts. Whatever! I don't actually give a damn what the reason is. Look, I've got a Genuine copy of XP! The validation check actually tells me 'Ok, you're doing fine'... Wow! Did I tell you this feels great? :)
Ok, now, back to reality.. To get a workable system, I need a lot more than just an OS. I decided not to use pirated software anywhere. This can get tough. It means not installing a cracked copy of Zone Alarm Pro or AVG Internet Suite; using AVG free edition and Sygate Personal firewall instead (hoping that they haven't made it too much of a crippleware). It means not getting a keygen for Getright and instead using Free Download Manager. But, let me tell you, it feels wonderful. And I'll bear with anything for this peace of mind...
So now, thanks a lot to Microsoft and all the other software developers who have spent countless hours of work and perhaps sleepless nights in making great software, and then have given it away for free to the public. Whether this was a business tactic or a genuine Good Samaritan-ness, this will be a great service to the public, and thou shalt be rewarded for it. Wish you good luck (do remember me when your lottery ticket wins $
76000000 :).
Love all...

Sunday 17 June 2007

Here we go...

So, this is the grand new start of our blog... By the way, The Tao (the title of the blog, in case you didn't notice..) means The Way (way with a capital W). It is based on the concept that there is a natural way of living for each of us, and the closer we get to that way of living, the happier we will be. This natural way is what is called the Tao.
I have no plans for this blog (in fact, I have no plans for almost anything in my life :) But I shall try to keep this entertaining and informative. I'll tell you the things I come across, things that matter to you and me, things that matter only to someone out there in Somalia, things that don't matter at all... anything you might find interesting.