This program is by Chris McCormack and is used here by permission.
This program is supplied without representation or warranty of any kind. Chris McCormack and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.
The underlying routine here caluculates the present value annuity factor (PVAF) based on the number of periods and the interest rate per period. Multiplying the payment by PVAF gives the total loan amount, while dividing the loan by the PVAF gives the payment size.
I've had this program sitting in my HP15C for a long time now. I've also used close relatives on the HP11C and HP33S. Not as fancy as some of the TVM programs people use, but nice to have ready when trying to talk turkey at a car dealership!
These routine perform loan calculations using the present value annuity factor, or PVAF. This relates the present value (loan amount) to the periodic payments necessary to pay it off.
PVAF(r,N) = (1/r)[1-1/(1+r)N]
In this equation, r is the decimal interest per payment period (.01 would represent a monthly loan with a 12% rate) and N in the number of payments (48 would correspond to a four-year car loan).
Note - Labels 9 and 6 were used because 9 is next to the divide key (breaking the loan down into payments) and 6 is next to the multiply key (building up the total loan amount).
001 LBL 9 // ( LoanAmt -- Payment ) 002 GSB .9 ÷ // divide present value by PVAF 004 RTN 005 LBL 6 // ( Payment -- LoanAmt ) 006 GSB .9 × // multiply payment by PVAF 008 RTN 009 LBL .9 // ( -- PFAV ) 010 RCL 0 1 + // R0 holds interest per period 013 LN RCL 1 CHS × // R1 holds number of periods 017 ex 1 x⇔y 020 - RCL 0 ÷ 023 RTN
Memory : 23 steps
Registers :
Labels :
$5000 borrowed at 10% with 36 monthly payments → $161.34 / month
10 ENTER 1200 ÷ STO 0 36 STO 1 5000 GSB 9
$1500/month on a 30 year mortgage at 7.5% → $215,526.44 borrowed
7.5 ENTER 1200 ÷ STO 0 30 12 × STO 1 1500 GSB 6
You can find the necessary interest rate to match payment and loan amounts by using the SOLVE function along with six more memory steps, one label, and one register. For example, find out what interest rate would allow a 1500/month payment to handle a 3 year, 5000 loan.
023 LBL A // can use any label 024 STO 0 // save current guess 025 GSB .9 RCL 2 - // can use any register except 028 RTN // R0 and R1
5000 ENTER 1500 ÷ // find PVAF needed (33.33) STO 2 36 STO 1 // save PVAF and number of periods .005 SOLVE A // won't work without good initial 1200 × // guess. convert to annual rate // (5.06%)
As noted in the HP-15C Advanced Functions Handbook, the math used for computing the annuity factors can suffer from roundoff errors when very low interest rates apply over a large number of periods. Using the technique outlined on page 181 of the handbook, an alternative subroutine .9 finds the correct answer.
009 LBL .9 // ( -- PVAF ) 010 STO I RCL 0 ENTER ENTER // save incoming x-register 014 1 + LN X⇔Y 018 LASTx 1 TEST 6 - // TEST 6 (X≠Y) 022 ÷ × RCL 1 × 026 ex 1/x 1 X⇔Y 030 - RCL 0 ÷ 033 RCL I X⇔Y // restore X value to stack 035 RTN // (above PVAF)
Running the example from the handbook, with 11.25% annual interest for payments each second (31,536,000 periods!) generates a present value annuity factor of 29,826,791.69 (instead of 33,221,310.84 returned by the original LBL .9 routine).
Go back to the software library
Go back to the main exhibit hall