Skip to content

Instantly share code, notes, and snippets.

@tonetheman
Forked from pathikrit/MortgageMath.md
Last active August 16, 2016 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonetheman/fe926ea3a6e3b689187983db2aecc528 to your computer and use it in GitHub Desktop.
Save tonetheman/fe926ea3a6e3b689187983db2aecc528 to your computer and use it in GitHub Desktop.
Mortgage Math

Input

p := 100000
apr := 3.0
t := 30

Calcuation:

r := apr/100/12                    # monthly interest rate
n := 12 * t                        # number of monthly payments

c(x) := 1 - (1 + r)^(-x)

m := p*r/c(n)                      # monthly payment

balance(i) := p*c(n-i)/c(n)        # balance at the end of the ith month

principal(i) := balance(i-1) - balance(i)    # principal part of the ith monthly loan payment
interest(i)  := m - principal(i)             # interest part of the ith month loan payment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment