Thursday, October 11, 2007

Calculating EMI or Mortgage

Lets use the following symbols.
r -> Rate of interest (For monthly installment with 6% APR, r is .06/12 = .005)
y -> Number of installments (For 30 yrs mortgage y = 30 * 12 = 600)
E -> EMI or Mortgage or Monthly payment.
P -> Loan/Mortgage amount.

In this blog I am going to show the mathematical derivation of each of the parameters (r, y, E, P) based on the known rest.

Calculation of EMI E based on P, r and y

Interest for the Loan amount P for the first payment is P * r and hence amount towards principle is E - (P * r)

Based on the above balance after first payment
B1 = P - (E - (P * r))
= P (1 + r) - E

Now balance after second payment
B2 = B1 - (E - (B1 * r))
= B1(1 + r) - E
= (P (1 + r) - E)(1+r) -E
= P(1 + r)^2 - E((1+ r) + 1)

Similarly balance after third payment
B3 = B2(1 + r) - E
= P(1 + r)^3 - E(1 + (1 + r) + (1 + r)^2)

At the end of y installation balance will be zero.
By = P(1 + r)^y - E (1 + (1+r) + (1+r)^2 + (1+r)^3 + .... + (1+r)^(y -1)) = 0

Applying Geometric proportion,
1 + a + a^2 + a^3 +...... a^n = (a^(n + 1) - 1) / ( a - 1)

0 = P(1 + r)^y - E ( (1 + r) ^y - 1) / r

=> E = Pr(1 + r)^y / ((1 + r)^y - 1)

Hence based on the loan amount P, rate of interest r and number of payments y we derive the monthly payment E as Pr(1 + r)^y / ((1 + r)^y - 1)

Calculation of Loan amount P based on E, r and y

E = Pr(1 + r)^y / ((1 + r)^y - 1)

Hence P = E ((1 + r)^y - 1) / r(1 + r)^y

Calculation of Number of payments y based on E, r and P

E = Pr(1+r)^y / ((1+r)^y - 1)

=> E((1+r)^y - 1) = Pr(1+r)^y
=> E(1+r)^y - E = Pr(1+r)^y
=> E(1+r)^y - Pr(1+r)^y = E
=> (1+r)^y ( E - Pr) = E
=> (1+r)^y = E/(E-Pr)

Taking log on both sides

y log(1+r) = log(E/(E-Pr))

=> y = log(E/(E-Pr)) / log(1+r)

Calculation of Rate r based on E, y and P

Still working on. It can be computed using computer software based on the Newton's iteration method .

Calculation of TotalInterest

Interest at every installment is balance of principle multiplied by rate.
As said in the Calculation of EMI,
Balance Bn = P(1 + r)^n - E ( (1 + r) ^n - 1) / r

Hence interest rate at an installment is Pr(1 + r)^n - E (1 + r) ^n + E
Therefore the total interest is sum of interest at every installation i.e 0 to n -1

Applying the sum of geometry proportion discussed before 1+a+a^2+...+a^n = (a^n - 1)/(a - 1)

Total interest will become
Pr ((1+r)^n - 1) / ((1 + r) - 1) + E ((1+r)^n - 1) / ((1+r) - 1) + En

= P ((1 + r)^n - 1) + E ((1 + r)^n - 1)/r + En


I have published in my site http://sudokusplashzone.com/mortgage/ a java applet for calculation of each of the parameter Rate, Payment, Loan amount and Number of payments based on the known rest.

No comments: