## Mortgage calculation with SAGE

• PMT: Payment
• PV: Present Value (loan’s principal, amount barrowed)
• r: monthly interest rate (compounded monthly)
• t: number of years of the loan
• m: 12 (compounding period)
• i: r/m=r/12 (intereset rate per compounding period)
• n: mt=12*t (loan’s term, number of monthly payments)

PMT(PV, i, n) = (PV*i)/(1-(1+i)^(-n))

PMT(PV, r, t) = (PVr/12)/(1-(1+r/12)^(-12t))

or with building functions on top of functions

PMT1(PV, r, t) = PMT(PV, i=r/12, n=12*t)

Example: 200,000 USD for a 30-year mortgage at 6.5% compounded monthly PMT(200000, 0.065, 30)

## Compounded interest calculation with SAGE

Suppose you deposit \$5000 in an account that earns 4.5% compounded monthly. You are curious when your total will reach \$ 7000. Using the formula A = P(1+i)n, where P is the principal, A is the amount at the end, i is the interest rate per month, and n is the number of compounding periods (number of months), we have

``````7000 = 5000(1+0.045/12)^n
1.4=(1+0.0045/12)^n
log 1.4 = log (1+0.0045/12)^n
log 1.4 = n log (1+0.0045/12)

SAGE: n = log(1.4)/log(1+0.045/12)
``````