Saturday, February 28, 2009

EMI Calculation formula -- proof

=== I'm confident that this proof is correct; but it is possible that there is a simpler proof existing for the same ==

P ==> Loan amount (principal)
E ==> EMI per month (to be derived)
n ==> tenure in months
R ==> rate of interest per month (to avoid cluttering of derivations, R is assumed to have been divided by 100. ie., for 12% p.a interest rate, it is 1% per month, so R is 0.01)

Let us derive the formula for outstanding-principal at the end of n EMIs (months):

outstanding-principal after month n = outstanding-principal after month n-1 minus principal component of the n'th EMI.

First month: P-(E-P*R) ==> P-E+PR ==> P(R+1)-E

Second month (n=2):
=> P-(E-PR)-(E-(P-E+PR)*R) => P-E+PR-(E+ER-(P+PR)*R) => -E-E-ER + P + PR + (P+PR)*R
=> -2E-ER + (P+PR)(1+R) => -E(R+2) + P(1+R)(R+1) = P(R+1)2 - E(R+2)

Third month (n=3):
=> P(R+1)2 - E(R+2) - E + PR(R+1)2 - ER(R+2)
=> P(R+1)2 + PR(R+1)2 -E -E(R+2) -ER(R+2) ==> P(R+1)3 - E(1+(R+2)(1+R))

Fourth month (n=4):
=> P(R+1)3 - E(1+(R+2)(R+1)) - E + PR(R+1)3 - ER(1+(R+2)(R+1))
=> P(R+1)4 -E -E(1+(R+2)(R+1)) -ER(1+(R+2)(R+1))
=> P(R+1)4 - E(1+(1+(R+2)(R+1))(R+1)) -------- (1)

Clearly the first portion of the outstanding principal has become a function of 'n'. I had to formulate the second portion ie., the co-efficient of E -> (1+(1+(R+2)(R+1))(R+1)) so I can come up with a outstanding-principal formula after n EMIs.

First approach:

1 ==> (R+1)0
R+2 ==> (R+1)0 + (R+1)1
1+(R+2)(R+1) == > 1 + R2 + R + 2R+2 ==> (R+1)0 + (R+1)1 + (R+1)2
1+(1+(R+2)(R+1))(R+1) ==> 1 + ((R+1)2+R+2)(R+1)) == > 1 + ((R+1)3+(R+2)(R+1))
==> (R+1)0 + (R+1)1 + (R+1)2+ (R+1)3

This translates to something like a0+a1+a2+a3...+an ; but I have no idea of any means to change this to a simple function of n.

So tried another approach to deduce:

R+2 => (R2+2R+1-1)/R ==> ((R+1)2-1)/R
1 + (R+2)(R+1) ==> 1 + ((R+1)2-1)*(R+1)/R ==> 1 + ((R+1)3-R-1)/R
==> 1 + ((R+1)3-1)/R - 1 == > ((R+1)3-1)/R
Similarly it can also be proved that for n=4 it is ((R+1)4-1)/R

Proof my mathematical induction:

Lets call this function P(k):

P(1) = ((R+1)1-1)/R => R+1-1/R => 1
Assuming P(k) is true, lets prove p(k+1).

based on the above recurrence, p(k+1) = 1+(R+1)P(k)
==> 1+(R+1) * ((R+1)k-1)/R ==> 1 + ((R+1)(k+1)-(R+1))/R
==> 1 + ((R+1)(k+1)-1)/R - 1 ==> ((R+1)(k+1)-1)/R ==> P(k+1)

Substituting the result in equation (1), the outstanding principal after n EMIs is: => P(R+1)n - E((R+1)n-1)/R

For the loan to end correctly, the outstanding principal at the end of n EMIs should be less than or equal to zero (if -ve, last month EMI will be smaller appropriately).

P(R+1)n - E((R+1)n - 1)/R <= 0 or E >= P(R+1)n / (((R+1)n - 1)/R) or
E >= PR(R+1)n / ((R+1)n -1)

EMI has to be as small as possible while completing the loan on time. So, computationally, for E to be a smallest possible round integer, >= can be converted to = by doing a ceil on the result.

So, E = ceil(PR(R+1)n / ((R+1)n -1))

where ceil(x) ==> smallest integer that is >= x e.g, ceil(1.5) = 2; ceil(2.1) = 3; ceil(2) = 2;

Hence proved :)

Friday, February 27, 2009

Life Moves Ahead To A New Beginning

Courtesy: PravsWorld

It is good to remember the past but don’t let the past capture your future.
The greatest thing about life is that is moves ahead and never goes back.

Just remember when it moves ahead, a new beginning starts.

Thursday, February 26, 2009


Whenever I mark a post as a ScriptedPost, the reader needs to be aware of the following:
  • This post has some portion of javascript underneath.
  • I assure that such scripts will not send any personal information from your computer to my servers. The scripts are put in only to enrich the post in the content so it reaches people better.
  • On readers like Google Reader or any other RSS readers, this post may not completely work the way it is supposed to -- as the scripts might have been stripped off for security reasons. You might probably want to see the post in a browser to get the complete effect.
  • I use Firefox and I only test my scripts against Firefox -- a decent standards compliant browser. It is possible that some (although not all) scripts might have difficulties while running on other browsers.

Loan EMI calculator

Many times people are in need of this. Be it home loan or personal loan or vehicle loan, the calculation of EMI is the same.

This calculator works for any of these loans with a monthly paid EMI and month reducing balance. Just key in the details and enjoy.

Loan amount
Rate of interest (% p.a)
Tenure (in months)

The calculated EMI is

One step further, if you need to calculate the EMI in your own application/webpage you can use this formula,

EMI = ceil(PR(R+1)n / ((R+1)n -1))


P ==> Loan amount (principal)
n ==> tenure in months
R ==> rate of interest per month (to avoid cluttering of formula, it is assumed to have been divided by 100. ie., for 12% p.a interest rate, it is 1% per month, so I is 0.01)
ceil(x) ==> smallest integer that is >= x e.g, ceil(1.5) = 2; ceil(2.1) = 3; ceil(2) = 2;

Note: I'm sure there are other websites that help you in calculating this, but this EMI calculator uses my "own" formula to calculate the EMI (don't get scared, it works :D). I will soon post a proof of my derivation of the formula.

Tuesday, February 24, 2009

64bit Windows file redirection

64bit Windows needs to be backward compatible with 32bit Windows world, so the existing 32bit Windows apps can run fine on a 64bit Windows.This is a fair and obvious requirement.

Obviously the system DLLs have to be different for the 32bit and the 64bit apps. As of 32bit windows, the system DLLs were loaded from %windir%\system32 folder (that's why named system32?). But contrary to one's expectation of a %windir%\system64 folder, MS has chosen to use the existing system32 (mind it, it is 32) folder to contain the new 64bit system DLLs (this I believe would have seemed contrary to MS too, but they probably had a architectural constraint that forced them to do so). Ok, so what happens to the 32bit DLLs? this is even more interesting. Unfortunately MS has not renamed the 64bit versions of the existing system DLLs; so the 32bit DLLs cannot be put into the same folder as the 64bit ones (system32); yes, so there is a 64bit version of user32.dll which resides in the system32 folder (you should make sure to remember that system32 is not a 32bit folder and user32.dll does not mean a 32bit DLL -- man this is really ugly). Ok, now that we've no choice, let's get on to the business. The 32bit DLLs reside at %windir%\sysWoW64 folder (did you notice the 64?). WoW64 probably means something like 'Windows on Windows 64', so it kinda make sense once you understand what is wow64 -- but at a first glance and to many, this nomenclature is confusing. You just need to get used to it.

The problem is not over yet. A 32bit application might try to load a system DLL from %windir%\system32 folder but the 32bit DLLs actually reside in sysWoW64 folder -- so yes, MS has implemented a redirector in WOW64 that redirects any file operation on %windir%\system32 by a 32bit application to %windir%\sysWoW64. A file operation by a 64bit application isn't redirected. But what if a 32bit app wants to access the "real" system32 folder -- then it needs access %windir%\sysnative which is a special virtual directory (shall be used only by 32bit apps) which would get mapped to the "real" 64bit system32 folder. To add to the confusion, there are few folders like catroot, drivers\etc, spool etc., which are not redirected to sysWoW64 and are shared by both the 32bit and 64bit applications. A relief here is that, these files can be accessed by both %windir%\system32\x and %windir%\sysnative\x -- this at least allows the applications to use %windir%\sysnative unambiguously.


Sunday, February 22, 2009

Future Is Yours

Courtesy: Pravs World

The future belongs to those who are willing to build it.
But you can’t build your future in the future.
You have to build it now.

The more ambitious your dreams, the sooner you must start working on making them real.
The future is yours.
Start today to make it exactly how you want it to be.

Friday, February 20, 2009

Outlook 2007 -- a mess

I've been happily checking emails in outlook 2003 and then I got outlook 2007.

Before I jump into the bigger ones, let me introduce you to some moderate issues. As soon as you open outlook 2007 for the first time, you will be taken aback -- yes the UI seems totally changed; believe me I was first impressed that it was enriched. But not for so long. Just when I click on new mail, I was shocked. The new mail dialog is totally totally (yes I typed it twice) changed. The toolbar is awful with large icons and all the usual stuff in new and different places; it's going to be a treasure-hunt for you even if you are an expert in outlook 2003. I spent at least 10 minutes to figure out how to enable digital signing of my emails. That apart, the title bar of any of the window (this applies to every product in MS office 2007) do not respect the windows's (OS's) theme settings. They show up in their own color and even worse, the active window's title bar color looks sooo dull that you would think that the outlook window is not active even on clicking on it.

After all those livable issues, there are issues that I'm not able to stand. Outlook 2007 is unacceptably ridiculously slow when it comes to dealing with PST mail files (specially when they are large -- mine is about 2GB). Outlook 2003 was perfectly fine dealing with PSTs of this size. To give you a number, my outlook 2007 takes around 30 minutes to download just 50 mails each of size less than 100KB (totalling to max 5MB) on a Intel Core 2 Duo 2.53GHz laptop with 2GB RAM running over a 1 Gbps network. And over the 30 minutes that it takes to finish, my hard disk is being thrashed almost continously (incase you thought, my hard disk is perfectly defragmented). My only guess is that Outlook 2007 is trying to do some kind of indexing on the incoming emails which is just going overboard because of the mail file size being 2GB or more. I could not find any option to disable that new "feature" to help me here. I managed to find a MS patch for Outlook 2007 that is supposed to fix this problem (to some extent at least) but no use -- my outlook 2007 still shucks!

Well, there are some work-arounds like minimizing the size of the PST file by backing up or archiving emails (I once started archiving and had to cancel it after 20-30minutes because I could see no progress except for the harddisk being continually thrashed). But I'm not here to do work arounds for migrating to a suppose-to-be better product at least by its version.

I'm at a point where I cannot probably turn back to outlook 2003, because I believe the new outlook would have considerably "worked" on the mailfile that the older one would fail to load. I can only see one thing happening: just like any other issues we face with the MS products, I will just get used to it one day!

Tuesday, February 17, 2009

Running 64bit guest on a 32bit host OS

=== This isn't something new, but worth a post. ===

Virtualization isn't something new but the concept of mixing the 32bit and 64bit software in the same machine at the same time is a milestone (atleast to me). This wouldn't be possible without a hardware support -- because a 32bit Virtual Machine Monitor (VMM) running on a 32bit host operating system has no way to make the 64bit code of the host OS to run "natively" (the processor does not understand 64bit code in 32bit mode even if it is 64bit capable).

Intel's Virtualization Technology (VT) provides support for virtualization at the hardware level. Obviously this is going to make the VMM much less complicated than earlier and provide much cleaner separation between the VMs. The VT technology offers lot of flexibility to the VMMs from the hardware level to implement virtualization. One of the most important (rather, otherwise impossible) feature is the support for mixed (32bit, 64bit) VMs to run at the sametime. Needless to say that this requires a "64bit" processor with VT technology enabled. Just VT cannot do magic on a 32bit CPU. In simple terms, VT allows the VMM to switch the processor mode to 32bit or 64bit at run-time as required so the guest OS does not have the restriction on the mode of the host OS.

My most favourite VM solution is VMware Workstation; while my favourite free one being VirtualBox. Both the solutions support VT and can run 64bit guest on 32bit host. (Vmware player is actually free -- but does not allow you to create VMs but only run; Infact VMware client to their ESX server is now open-source -- more info).

VT feature has to be enabled at the BIOS -- might be available in some advanced configuration. I was surprised to see this option on my machine under 'Security' section in BIOS :)

Anyways, this is just wonderful!!!

Saturday, February 14, 2009

An interesting human interface

This video from TED shows David Merill demonstrating his invention of a new form of human interface to computers. Interesting!!

The video says the rest

Tuesday, February 10, 2009

Car wash in Bangalore

It is actually surprising that there are (almost) no car wash centers readily available in Bangalore. I searched the net and enquired with my friends and colleagues -- but the answer is just the same. It would actually be a good business to start a professional car wash center in Bangalore.

The only one decent car wash center (as of this writing) is the SLV Car wash center, South End road (Old Kanakapura road), Basavanagudi, Bangalore (near Caritor office). If you drive from South-end circle on the south-end road, at the first intersection, on your right is this place. There is a huge board saying 'Car bath' :)

I've been using their service for quite sometime and am reasonably happy with them. The charges are little on the higher side though. They charge Rs. 225 (earlier Rs.200) for small sized cars (like Indica, zen, alto, swift etc.,) and Rs. 300 for SUV sized cars (like scorpio, safari etc.,) The wash includes exterior and interior cleaning.

The sequence of cleaning goes like this:
  1. While the car is in queue for the body wash, they would bring a mobile vacuum cleaner and clean the interiors; the floor mats will be taken out for washing separately.
  2. Before the car reaches the body wash place, the interiors will be all set.
  3. Then they wash the car with pressurized water (they have provision to even wash under the chassis of the car).
  4. They clean the tyres (no they don't remove them) with soap water.
  5. Now the car is driven into the automatic wash drive bay. The auto-wash first sprays pressurized water all over the car; then a lot of soap oil; then under heavy pressure water cleans it off. For the first time, it's fun to watch the machine doing it.
  6. As the car is driven out of the auto wash area, there is a blower which blows hot air to dry up the car faster; with its aid, the workers manually wipe out the water from the car's body.
  7. Meanwhile, the glass, side-view mirrors are cleaned and the floor mats are put back in place and the car is all set for delivery.
All in all I like their work. If there is heavy crowd, they tend to mess-up (like, this time they had put back the floor mats of another car; fortunately I figured out before delivery). Overall the wash is semi-automatic. Even if the interiors are not so neatly done by chance (you can stand with them while they do it if you need it perfectly done), the exterior wash is really good. Nothing can escape from their near 4 times wash with pressurized water. Weekends are usually crowded. They spend around 20-25 mins per car. On an average be ready to spend at least an hour there (including the waiting time). Weekday's early morning might be a better slot.

Saturday, February 07, 2009

Inside an infected laptop

A non-techy friend of mine had bought a laptop 2 months back. As he wasn't aware of installing the OS and software etc., I installed all the required software for him. Just after 2 months, last week, he complained saying "nothing" works. He said that the computer is saying 'you are at risk', 'your system lacks security', 'the winamp is not playing' etc., etc., He was even worried that the speaker is blown up. I got the laptop back from him to set it right for him.

As I am not a service engineer (who would have formatted the laptop right away and installed everything fresh), I wanted to discover each and every portion of the problem before I recover the laptop. I wanted to have some real-time experience on an infected machine. It was actually funny to see each trojan and worm's behavior.

The laptop boots and the desktop starts to come up. There is no welcome music -- the sound card driver is gone for a toss. The (fake) Windows security center pops up saying 'Your computer is not running an anti-virus and might be at risk'. Then, I get a popup saying 'your computer is infected, do you want to scan for viruses'. The program calls itself 'Internet Antivirus Pro' and presumes the user is an idiot. Without the user's permission it starts scanning the computer (yes, everytime the user logs in). The funny part is that, the software doesn't bother to read the files at all while scanning. It was clear from the hard-disk usage that no files were read. The software managed to scan thousands of files in less than a minute. One smart thing it did to make the user believe was to really pickup some files from the user's Documents and Settings folder, so it looks as though they were real scans. When you know what it is doing, it is just funny -- but if you are a non-techy user there is no surprise that you would panic. At the end the software asks 'do you want to clean these viruses?'. If you say yes, it takes you directly to a payment site and you will be billed for nothing. Uhh!!

As I was looking at the billing page for any identity, I could see the Internet Explorer's title bar saying -- "Internet Explorer -- hacked by xyz" (I don't remember the exact name). Aha! The next one. Having known that it is possible to change the IE's title bar in registry, I searched for scripts with the appropriate registry key path (maybe not, I don't want to publish the path here) and hurray! I managed to get hold of the script. Thankfully it was a script and not a binary. The script had successfully managed to propagate itself to all the drives and into the \WINDOWS folder. The script spreads itself through autorun.inf in Windows (autorun.inf seems to create more problems than it solves). Whenever you double-click on a drive, the autorun.inf (if any) on that drive's root folder gets executed. This is the heart of this worm. It copies itself into all other drives, specially looking for any flash disks connected to the computer and replicates. In addition, this script registers itself with Windows to get executed on startup. So anytime, you start the computer with any removable drive, it gets infected too. This worm was later identified as 'VBS:Solow-L (worm)' by avast!.

The last one is the sound card issue. I believe this is also caused by the IAPro worm that I had discussed earlier. A close look at the device manager revealed that the sound card is powered by a device driver which is not digitally signed by anyone; and the publisher name seems to say "unknown". The driver was smart enough to claim that it supports the sound card's device instance id so that windows loads this same driver every time -- even if I uninstall/reinstall the hardware or disable/enable the sound card. I had to rollback to the earlier driver to make it work.

There was no other visible sign on the laptop that needed to be addressed although there were many other resident viruses/worms. Just installed avast! and it found around 20+ viruses spread out in around 520 files. It isn't surprising me now that a laptop was infected with so many viruses in such a short-time. I think with a little promising note, any website can make an average non-techy user to install their software and get control of their machine. Even a simple popup in the browser stating 'Your computer is infected, do you want to scan for viruses' might do the trick. No wonder phishing has become so easy and common. Lack of fundamental exposure is the issue here, but the users cannot be that easily blamed for their ignorance. After all this isn't their cup of tea. Hmm, computer is a complicated device to understand but a life without it is becoming inevitable in this modern era. Using a computer with no understanding is starting to be dangerous when connected to the Internet!!

Whatever it is, I enjoyed the exercise :)

Thursday, February 05, 2009

Unix time approaching a special value on a special day

Unix time or POSIX time is the representation of time as the number of seconds elapsed since January 1, 1970 00:00:00 UTC. Even though it is derived from UNIX, it is widely used across all the platforms including Windows.

Unix time reaches the value of 1234567890 on this "Valentine's day" (at 2009-02-14 00:01:00 UTC) -- A special value on a special day :)

On a side note, the unix time had earlier reached 1,000,000,000 on 2001-09-09 01:46:40 UTC and will overflow the 32-bit boundary (actually 31-bit + 1 signed bit) in 2038-01-19 around 03:14:07 UTC. This overflow is expected to cause many software that do not handle this overflow, to fail in the year 2038 -- the Y2K38 problem.

Tuesday, February 03, 2009

My pencil arts - #3 - Ghajini

turned out to be Ghajini-lookalike ;)

Sunday, February 01, 2009

MP5 player -- what is it?

On the other day, I was surprised to see some items in ebay named 'MP5 players'. Just like anyone else would, I really thought it would play MP5 format -- I was also feeling bad that I had no idea about the all new MP5 format. So did some search to find out what's new in MP5 than MP4 and here it is.

There is no such encoding standard as MP5. But Chinese players are available which claim to be a player for an encoding (MP5) that does not exist -- it seems that the only reasoning behind this is ignorance. Had they understood MP3 and MP4, maybe they would have named this better. There is no clear explanation as to why this was named MP5 except for that fact that they wanted to convey that these new players are better than the older MP4 players and the name should be easy to remember and should convey the meaning by itself.

The new so-called MP5 players play a wide variety of formats specially video, including MP4, MPEG, AVI, RMVB, FLV, WMV etc., Some webpage claimed that RMVB (RealMedia Variable Bit-rate) encoding is the so-called MP5 -- but I don't think so.

To keep this Chinese nomenclature simple, MP3 players play audio files, MP4 players play audio and video files, MP5 players play audio and more video files. I've personally seen MP4 players that can play some video but not even MP4 -- so forget about what it means to be an MP5 player. The best way to analyze the players is probably by going through the formats supported (if at all you believe the list is correct), because not all MP5 players are same except for the fact that they can't play MP5.