# Appendix D: Optional Function Libraries

## D.1 Finance Methods

This is an optional library that supports a variety of common financial calculations for interest rates, monthly payments etc.

apr(n1, n2, n2)
Returns the annual percentage rate for a loan, where n1 is the principal amount of the loan, n2 is the monthly payment, and n3 is the number of months payments will have to be made. For example "```apr(35000, 269.50, 30 times 12)```" returns 0.085 (or 8.5%) for the annual interest rate on a loan of \$35,000 being repaid at \$269.50 per month over 30 years.
cterm(n1, n2, n2)
Returns the number of periods needed for an investment earning a fixed, but compounded, interest rate to grow to a future value, where n1 is the interest rate per period, n2 is the future value of the investment, and n3 is the amount of the initial investment. For example "`cterm(.02, 200, 100)`" returns 35 as the required period for \$100 invested at 2% to grow to \$200.
fv(n1, n2, n3)
Returns the future value of periodic constant payments at a constant interest rate, where n1 is the amount of each equal payment, n2 is the interest rate per period, and n3 is the total number of periods. For example "```fv(100, .075 over 12, 10 times 12)```" returns 17793.03 as the amount present after paying \$100 a month for 10 years in an account bearing an annual interest of 7.5%.
ipmt(n1, n2, n2, n3, n4, n5)
Returns the amount of interest paid on a loan over a period of time, where n1 is the principal amount of the loan, n2 is the annual interest rate, n3 is the monthly payment, n4 is the first month of the computation, and n5 is the number of months to be computed. For example "```ipmt(30000, .085, 295.50, 7, 3)```" returns 624.88 as the amount of interest paid starting in July (month 7) for 3 months on a loan of \$30,000.00 at an annual interest rate of 8.5% being repaid at a rate of \$295.50 per month.
npv(n1, n2 [, ...])
Returns the the net present value of an investment based on a discount rate, and a series of periodic future cash flows, where n1 is the discount rate over one period, n2 ... are cash flow values which must be equally spaced in time and occur at the end of each period. For example "```npv(0.15, 100000, 120000, 130000, 140000, 50000)```" returns 368075.16 as the net present value of an investment projected to generate \$100,000, \$120,000, \$130,000, \$140,000 and \$50,000 over each of the next five years and the rate is 15% per annum.
pmt(n1, n2, n3)
Returns the payment for a loan based on constant payments and a constant interest rate, where n1 is the principal amount of the loan, n2 is the interest rate per period, and n3 is the number of monthly payments. For example, "```pmt(30000.00, .085 over 12, 12 times 12)```" returns 333.01 as the monthly payment for a loan of a \$30,000, borrowed at a yearly interest rate of 8.5%, repayable over 12 years (144 months).
ppmt(n1, n2, n2, n3, n4, n5)
Returns the amount of principal paid on a loan over a period of time, where n1 is the principal amount of the loan, n2 is annual interest rate, n3 is the monthly payment, n4 is is the first month of the computation, and n5 is the number of months to be computed. For example "```ppmt(30000, .085, 295.50, 7, 3)```" returns 261.62 as the amount of principal paid starting in July (month 7) for 3 months on a loan of \$30,000 at an annual interest rate of 8.5%, being repaid at \$295.50 per month. The annual interest rate is used in the function because of the need to calculate a range within the entire year.
pv(n1, n2, n3)
Returns the present value of an investment of periodic constant payments at a constant interest rate, where n1 is the amount of each equal payment, n2 is the interest rate per period, and n3 is the total number of periods. For example "`pv(1000, .08 over 12, 5 times 12)`" returns 49318.43 as the present value of \$1000.00 invested at 8% for 5 years.
rate(n1, n2, n3)
Returns the compound interest rate per period required for an investment to grow from present to future value in a given period, where n1 is the future value, n2 is the present value and n3 is is the total number of periods. For example "`rate(110, 100, 1)`" returns 0.10 as what the rate of interest must be for and investment of \$100 to grow to \$110 if invested for 1 term.
term(n1, n2, n3)
Returns the number of periods needed to reach a given future value from periodic constant payments into an interest bearing account, where n1 is the payment amount made at the end of each period, n2 is the interest rate per period, and n3 is the future value. For example "`term(475, .05, 1500)`" returns 3 as the number of months for an investment of \$475, deposited at the end of each period into an account bearing 5% compound interest, to grow to \$1500.00.