5.19. Calculating Loan Amortization or Annuities
Problem
You want to determine the monthly
payment it takes to pay off a loan (i.e.,
amortize
the loan). Alternatively, you want to
know how much money you can withdraw from a retirement account on a
periodic basis.
Solution
Calculate the payments using the custom Math.PMT(
)
function.
Discussion
Suppose you want to borrow $100,000 from a bank, and you need to know
the required monthly payment to pay back the loan. The answer
requires the bank to calculate how much money is needed to pay off
the principal and the interest that accrues before the loan is
finally paid off in full. The calculation is equivalent to the one
needed to calculate how much money you can take out monthly from a
retirement account. However, in the case of a so-called
annuity
, you start with the lump sum and extract
a series of periodic payments. The math still answers the question,
“Given an initial pile of money and the prevailing
interest rate, how much money can I take out (or must I pay back)
each month before the balance is zero?”
The following custom Math.PMT( )
function
returns the same value as the one obtained in Microsoft Excel using
the Insert → Function → Financial
→ PMT formula. You can add this to your
Math.as
file for easy inclusion in other
projects.
Math.PMT = function (i, n, PV) { //PV
= initial savings deposit or loan amount (present value) //i
= periodic interest rate //n
= number of payment periods //PMT
= periodic payment // Calculate ...
Get Actionscript Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.