In "Calculating EMIs", we derived the formula for calculating the "Equated Monthly Installment" (EMI) on a loan. If "E" represents the EMI, "P" represents the principal amount in the loan, "r" represents the monthly rate of interest (one way of arriving at it is to divide the annual rate of interest, quoted as a percentage, by 1,200) and "n" represents the number of months in the tenure of the loan, then:
E = P × r × (1 + r)^{n} / ((1 + r)^{n}  1)
In the current example, we know the values for "E", "P" and "n" and wish to calculate "r". Unfortunately it is not that simple to calculate "r" using just the highschool algebra that most of us manage to remember. Fortunately there is a simple algorithm that can help us in this situation.
Let us first rewrite the formula above as an equation:
P × r × (1 + r)^{n} / ((1 + r)^{n}  1)  E = 0
Our task now is to find the roots of this equation  that is, the values of "r" that will make the lefthandside (LHS) of this equation evaluate to zero.
To find the roots of a given equation "f(x) = 0", the algorithm in question can be described as follows:
 Find a value "a" for which "f(a)" evaluates to a negative value.
 Find a value "b" for which "f(b)" evaluates to a positive value.
 Let "c" be the average of "a" and "b".
 If "f(c)" is close enough to zero, "c" is the desired root.
 Otherwise, if "f(c)" is a negative value, substitute "c" for "a" and repeat the procedure from step #3 and if "f(c)" is a positive value, substitute "c" for "b" and repeat the procedure from step #3.
Note that this is just a binary search algorithm. By "close enough to zero", we mean that the absolute value of "f(c)" is less than some value, usually called "epsilon", that can be as small as we please. The algorithm given above can be rewritten as a function in a pseudolanguage as follows:
guessRoot( f, a, b)
{
c := (a + b) / 2;
if( absoluteValue( f( c)) < EPSILON)
return c;
else if( f(c) < 0)
return guessRoot( f, c, b);
else
return guessRoot( f, a, c);
}
You can implement this in your favourite programming language along with a function that calculates the LHS of the equation given earlier. You can choose a value of "epsilon" according to your preference  the smaller the value of "epsilon", the more accurate is the result and the longer it takes to compute it. The time taken for the computation is also affected by how wide is the range between "a" and "b". Note that Newton's method is a much faster way of computing the roots of such equations, though it involves calculating derivatives.
How do you arrive at the values for "a" and "b"? This differs for each function. For our example, we can start with a low guess of "0.001%" ("0%" gives an undefined result) as the annual rate of interest and a high guess of "100%" and this gives us a negative and a positive value for the LHS respectively. With an "epsilon" of "0.00001", a C programme computes the answer in around 25 iterations.
In our example, the first dealer is offering us an effective loan of Rs 50,000 for 12 months with an EMI of Rs 4,380 and the effective annual rate of interest comes to about 9.32%. The second dealer is offering us an effective loan of Rs 40,000 for 36 months with an EMI of Rs 1,330 and the effective annual rate of interest comes to about 12.08%. In terms of the interest rates being charged by the dealers, you should now be able to tell that the first dealer has a better proposition for you when compared to the second dealer.

Tweet 

It would be nice if to have such an algo implemented in J2ME so that we can use it on our mobiles.
ReplyDeleteHmmm...!!
ReplyDeleteVery Innovative indeed...!! :)
Reminds me of Something ExtreeeeMely Brilliant that Newton did...to discover Simply the Mosst Amazing way to quickly find the value of Pi...!! :)
i do not not like math at all
ReplyDeleteThanks man. I spent 2 hours trying to figure this out using my knowledge of algebra. Then I gave up and looked online to find you.
ReplyDeleteBy the way, you can use the RATE function in Excel for this.
WHAT MAN ITS VERY DIFFICULT FOR A COMMON I.E FOR COMMERCE BACKGROUND STUDENTS UNDERSTANDING OF F(X),(A) ,(B) ETC.... IT IS MORE HELPFUL TO MATHS STUDENT VERY DISAPPOINTED SORRY.........
ReplyDeleteHow to find value of a and b?
ReplyDelete