Interest algorythm

I was thinking about writing a JAVA program (I just took an intro class at work) to figure out total cost, interest, etc. on a loan. Since I’m feeling a bit lazy at the moment (and my JAVA book is at work), I wonder if anyone knows an algorythm I can code. I’m not looking for the code itself, just the logic. I’m thinking it’s something like this:

principal + (interest * principal / 12) - payment = new-principal

Using a “while” loop, I can total up the amount payed over the life of the loan.

Given the principal amount and the interest rate, what are the formulas for figuring out the monthly payment? That is, “The loan is for $125,000. The interest rate is 10%. The term is 10 years.” What formula will allow me to input these parameters and spit out a monthly payment amount?

Oops. “Algorithm”.

Essentially what you have to do here is calculate the value of an annuity whose present value is P.

Let’s say for the sake of argument (and also because it’s the only way I know how to calculate it :slight_smile: ) that the bank is going to compound its interest at the same interval that you’re going to be making your payments (IE, monthly).

Let’s call the present value of the annuity (IE, what the bank is going to give you right now) P.

Let’s call the monthly Annuity amount (what you’ll be paying the bank) A.

Let’s call the total number of payments you’ll be making N.

Let’s call the annual interest rate Y (expressed as a decimal, IE a 10% interest rate = 0.1). Remember, though, that we’re going to be compounding monthly.

Let’s call the monthly interest rate I (again, expressed as a decimal).

First, we have to calculate the monthly interest rate from the annual interest rate. Because we’re compounding, we need to take the twelfth root of (1 + Y):

(1 + I) = (1 + Y) ** (1/12)
or
I = ( (1 + Y) ** (1/12) ) - 1

Then the Annuity amount is (formula from the CRC Standard Mathematical Tables, 17th edition, page 631):

A = P * ( I / (1 - ((1 / (1 + I)) ** N)))

In terms of your example,

P = 125000
Y = 0.10
I = ( (1 + Y) *** ( 1 / 12) ) - 1 = .007974
A = (the above formula) = $1622.19

…unless I’ve gotten something wrong.

hee hee… “Al Gore Rhythm”…hee hee…no such thing…


I mis-wasted my youth.

WillGolfForFood,
Thanks for the equation.

Okay, IIRC, ****** is “to the power of”. Is that correct? What is *******? (It sucks not having a programming reference at-hand!)

I’ll whip up a program when I get to work and see how close this helicopter is! Thanks again! :slight_smile:

AzRaek,
Funny, I was thinking the same thing!

Yes.

That was me stuttering. :slight_smile: Seriously, that should have been another ‘**’. My bad.

Johnny, I am not sure the above answers are entirely correct (they may be but I am not sure I understand them correctly).

Here’s the straight dope and I hope it will clarify rather than confuse.

The way a mortgage is calculated is monthly so in reality 9% yearly is .75% per month which is not the same thing. So the loan is really for 360 months at 0.75% rather than 30 years at 9%. That is the way it is calculated.

You can easily make a table calculating month by month the interest, principal etc.

The question of how to calculate the monthly payment is easy. Let
K be the Capital (amount of loan)
i be the interest for the period (month)
n be the number of periods (months)
the monthly payment is given by:

        i

K * ------------------
1
1 - ----------
(1+i)^n

just to make sure; an $80000 loan for 30 years at 9% requires a monthly payment of 643.70

While I am not a professional in this field I am good with numbers and some years ago became quite an expert when I was thinking of refinancing. I found that most loan officers are quite ignorant of the basics. I do not know what is your interest but I would be glad to share my knowledge. You may want to think about:

How do you compare two loans? what is better, a loan with a higher interest rate and no points or the one with points and lower interest rate? I have not found anybody who can give a straight answer and the analysis is quite simple. I can give you the answer in seconds.

After you analize the previous question you will see that, in effect, points constitute a prepayment penalty. When prepayment penalties were outlawed, lenders invented “points”: same dog with a different collar.

:slight_smile:

I messed up the formula above not realizing the HTML would take all the spaces out… sorry about that… let me try again
<pre>
i
a = K ---------------
1
1 - ---------
(1+i)^n
where
a is the payment for the period (month)
K is the total capital (loan)
i is the interest for the period (month)
n is the number of periods (months)
^ is “elevated t”

</pre>
in a spreadsheet you would write (I hope I can get this right):
K*i/(1-(1/(1+i)^n))

let’s see if this appears formatted correctly

Oops, sorry again. I will not even try any more. I have posted the formulat at

http://www.geocities.com/alf_gon/k.gif

I hope this works out

Sailor - I just looked at your GIF, and, although we used different words to explain the situation, the two formulas that you and I gave are identical.

(Just dividing the annual percentage rate by 12 gives you a close approximation to the monthly rate, but not an exact one. You really have to take the twelfth root to be precise.)

Points are just an extra fee (expressed as a percentage of the loan) that a bank charges as part of making the loan. Think of them as shipping and handling. :slight_smile: Essentially, you end up borrowing more money (either from the bank or another source) as a result. The banks have to factor in those points when they give you the loan’s effective APR, and so should you.

Will,

>> (Just dividing the annual percentage rate by 12 gives you a close approximation to the monthly rate, but not an exact one. You really have to take the twelfth root to be precise.)

No, sir. When the bank tells you they will lend you at x% per annum they really mean they will lend you at x/12 % per month (X% per annum compounded monthly, which means you are actually paying more than x% per annum). I had a mortgage at 9% and I was paying 0.75% per month. Check it out with any bank. What is true is that if the bank says you are paying x interest per year, the actual rate you pay is higher. I believe this actual rate is what the call APR.

>> Points are just an extra fee …

I know very well what points are and what I am saying is that they are, in effect, a prepayment penalty. If you do a detailed financial analysis you will see it.
(I hope I do not have to go into a demonstration using examples because I have done it a couple of times in the past and it is more work than I feel like doing… not to mention it would bore most people to death. By the time we are done I am the only one paying attention)
When I was thinking of refinancing I did a spreadsheet that would compare two loans, points and all. I still have it.

OK. here are some questions. Compare these pairs of loans and tell me which one is better and why and how they compare:

Let us make them all 30 year loans to make it simpler:

A- 9%, 0 points VS 8.5%, 3 points
B- 6%, 1 point Vs 5.5%, 2 points

Anyone wanna tell me? I am amazed at how even loan people in banks can only give you vague rules of thumb. I can plug the numbers into my spreadsheet and tell you instantly.