| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 1836.1 | May want to ask the pros | VMSDEV::HALLYB | Fish have no concept of fire | Mon Jan 31 1994 21:47 | 6 | 
|  |     I'm sure this is answered, probably with sample programs, in
    TALLIS::REAL_ESTATE.
    
    Of course, it would also be nice to have the algorithm here, too.
    
      John
 | 
| 1836.2 | my mortgage.com in dcl ! | HANNAH::OSMAN | see HANNAH::IGLOO$:[OSMAN]ERIC.VT240 | Tue Feb 01 1994 13:40 | 76 | 
|  | $!
$!	Procedure to calculate monthly payment, in dollars, to pay off
$!	a given loan at a given yearly interest rate for a given number of
$!	years.
$!
$!	Author:   Eric Osman   10-Feb-1993
$!
$ set = "set"
$ set symbol/scope=(nolocal,noglobal)
$ on warning then stop
$ loan = p1
$ if loan .eqs."" then read/prompt="How much is loan (in dollars ONLY) ? " -
    sys$command loan
$ percent = p2
$ if percent .eqs. "" then read/prompt="Percentage rate (decimal point ok) ? " -
    sys$command percent
$ years = p3
$ if years .eqs. "" then read/prompt="How many years (NO decimal point) ? " -
    sys$command years
$ loan = f$int(loan)
$ scale = 0
$ if percent - "." .nes. percent then -
    scale = f$len(percent) - f$loc(".",percent) - 1
$ percent_num = percent - "."
$ percent_den = "1" + f$fao("!#*0",scale)
$ percent_num = f$int(percent_num)
$ percent_den = f$int(percent_den)
$ monthly_installments = years*12
$ low_payment = 0
$ high_payment = 10000
$ months = years*12
$ guess_payment = 0
$ guess_payment = (low_payment+high_payment)/2
$ try_lup:
$ old_guess = guess_payment
$ write sys$output "Trying a payment of $", guess_payment
$ call calculate_installments 'loan' 'guess_payment' 'percent_num' 'percent_den'
$ new_installments = $status/2
$ if new_installments .lt. monthly_installments
$ then
$	high_payment = guess_payment
$	message = "Too much..."
$ endif
$ if new_installments .gt. monthly_installments
$ then
$	low_payment = guess_payment
$	message = "Too little..."
$ endif
$ guess_payment = (low_payment+high_payment)/2
$ if guess_payment .eq. old_guess
$ then
$	write sys$output "That's it !"
$	exit
$ else
$	write sys$output message
$ endif
$ goto try_lup
$ calculate_installments: subroutine
$ on warning then stop
$ owed = f$int(p1)
$ payment = f$int(p2)
$ yearly_percent_num = f$int(p3)
$ yearly_percent_den = f$int(p4)
$ installments = 0
$ new_int = 1000000
$ lup:
$ old_int = new_int
$ installments = installments + 1
$ remaining = owed - payment
$ new_int = remaining*yearly_percent_num/1200/yearly_percent_den
$ if new_int .gt. old_int then exit 10000*2+1
$ owed = remaining + new_int
$ if owed .gt. 0 .and. new_int .gt. 0 then goto lup
$ exit installments*2+1
$ endsubroutine
 | 
| 1836.3 | not a clean solution | POLAR::MOKHTAR |  | Tue Feb 01 1994 16:07 | 13 | 
|  |     
    Thanks for the replies.
    the method used in .2 has the same problem as i mentioned in the base
    note. It does not directly solve an equation for payments as functions
    of principle, rather it iterates guessed values of payments and tests 
    them in the equation i mentioned in .0 ( the equation for principle as 
    function of payments ). I thaught of such method but i prefer a better 
    way.
    
    Is there an equation that directly solves for payments ?                   
    Thanks 
         
    
 | 
| 1836.4 |  | AUSSIE::GARSON | Hotel Garson: No Vacancies | Tue Feb 01 1994 17:12 | 7 | 
|  | re .3
    
>    Is there an equation that directly solves for payments ?
    
    Yes, that mortgage payment recurrence can be solved in closed form i.e.
    down to an exponentiation. I did it about a year ago when I bought my
    house. I'll see whether I can locate the envelope in question.
 | 
| 1836.5 |  | 3D::ROTH | Geometry is the real life! | Tue Feb 01 1994 20:36 | 15 | 
|  |     If p is the principal q is the payment, and a is the interest
    per payment period (say, annual interest/12) then telescoping the
    expression from one month to the next for n payments would give you
                (1+a)^n
	q = a ----------- p
              (1+a)^n - 1
    to make the final payment finish off the loan.
    So, if you had a 10 year loan with a 6 percent APR, you'd have
    a monthly payment of 11.102050 per thousand dollars, I don't
    know what the policy is for rounding off though.
    - Jim
 | 
| 1836.6 |  | POLAR::MOKHTAR |  | Tue Feb 01 1994 21:56 | 5 | 
|  |     
    
    Thanks v much.
    
    mm
 | 
| 1836.7 | Up. | CADSYS::COOPER | Topher Cooper | Wed Feb 02 1994 11:05 | 11 | 
|  | RE: .5 (Jim)
>    So, if you had a 10 year loan with a 6 percent APR, you'd have
>    a monthly payment of 11.102050 per thousand dollars, I don't
>    know what the policy is for rounding off though.
    I checked that particular example against a loan amatorization (sp?)
    table and it gave a monthly payment of $11.11 -- i.e., the policy is
    to "round up."
				Topher
 | 
| 1836.8 |  | AUSSIE::GARSON | Hotel Garson: No Vacancies | Wed Feb 02 1994 21:16 | 6 | 
|  |     re .7
    
    ...ignoring rounding in the interest calculation itself (which was not
    accounted for in the previous)
    
    P.S. sp: amortization
 | 
| 1836.9 | more formulas | OUTSRC::HEISER | watchman on the wall | Wed Feb 28 1996 16:02 | 13 | 
|  |     Here's some more formulas if anyone is interested:
    
    Total Interest for Life of loan = 
    	Period * (Monthly Payment + Extra Payment) - Beginning Principal
    
    Monthly Interest = Balance * Interest Rate
    
    Monthly Principal = (Monthly Payment + Extra Payment) - Monthly Interest
    
    Period = absolute value of ln(1-Principal*(i/Payment)) / ln(1+i)
    
    regards,
    Mike
 |