Add largest affordable loan
This commit is contained in:
parent
73b7574190
commit
4280ae7585
@ -1,16 +1,6 @@
|
|||||||
;;;; Mortgage Calculators
|
;;;; Mortgage Calculators
|
||||||
|
|
||||||
#|
|
#|
|
||||||
loan amount (p)
|
|
||||||
interest rate (r)
|
|
||||||
years (t)
|
|
||||||
payments per year (n)
|
|
||||||
loan type: fixed-rate
|
|
||||||
|
|
||||||
Payment = P x (r/n) * [1+(r/n)^n * t]/(1+r/n)^n *t - 1
|
|
||||||
|
|
||||||
or
|
|
||||||
|
|
||||||
P = payment
|
P = payment
|
||||||
PV = Present Value
|
PV = Present Value
|
||||||
r = rate per period
|
r = rate per period
|
||||||
@ -18,16 +8,45 @@ n = number of periods
|
|||||||
|
|
||||||
P = (r(PV)) / (1-(1+r)^-n)
|
P = (r(PV)) / (1-(1+r)^-n)
|
||||||
|
|
||||||
|
Okay, but I want to find PV instead
|
||||||
|
Guess I need to remember algebra
|
||||||
|
|
||||||
|
P = (r(PV)) / (1-(1+r)^-n)
|
||||||
|
P * (1-(1+r)^-n) = r * PV
|
||||||
|
|
||||||
|
(P * (1-(1+r)^-n) / r = PV
|
||||||
|
|
||||||
|
monthly-payments conversion
|
||||||
|
|
||||||
|
(find-payments loan-total (/ rate 12) (* number-of-payments 12)))
|
||||||
|
find-payments = loan-total
|
||||||
|#
|
|#
|
||||||
|
|
||||||
(defun payments (loan-total rate number-of-payments)
|
(defun find-payments (loan-total rate number-of-payments)
|
||||||
|
"Base loan calculation"
|
||||||
(/ (* rate loan-total)
|
(/ (* rate loan-total)
|
||||||
(- 1 (expt (+ 1 rate) (* number-of-payments -1)))))
|
(- 1 (expt (+ 1 rate) (* number-of-payments -1)))))
|
||||||
(defun monthly-payments(loan-total rate number-of-payments)
|
|
||||||
"Number of payments in years"
|
(defun find-monthly-payments(loan-total rate number-of-payments)
|
||||||
(payments loan-total (/ rate 12) (* number-of-payments 12)))
|
"Modify loan calculation to show monthly payments"
|
||||||
(defun payment-total-per-year (loan-total rate number-of-payments)
|
(find-payments loan-total (/ rate 12) (* number-of-payments 12)))
|
||||||
(* (payments loan-total (/ rate 12) (* number-of-payments 12)) 12))
|
|
||||||
|
(defun find-montly-payment-total-per-year (loan-total rate number-of-payments)
|
||||||
|
"Modify loan calculation to show total montly payments per year"
|
||||||
|
(* (find-payments loan-total (/ rate 12) (* number-of-payments 12)) 12))
|
||||||
|
|
||||||
|
|
||||||
|
;; fixme: add function to take monthly-payments rate num-of-payments
|
||||||
|
(defun find-biggest-loan (payments rate number-of-payments)
|
||||||
|
"Base loan calculation"
|
||||||
|
(/ (* payments
|
||||||
|
(- 1 (expt (+ 1 rate)
|
||||||
|
(* -1 number-of-payments))))
|
||||||
|
rate))
|
||||||
|
|
||||||
|
(defun find-biggest-loan-monthly (payments rate number-of-payments)
|
||||||
|
(find-biggest-loan payments (/ rate 12) (* number-of-payments 12)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user