(15C) Accurate TVM for HP-15C
01-10-2014, 03:36 AM (This post was last modified: 01-02-2016 01:46 PM by Jeff_Kearns.)
Post: #1
 Jeff_Kearns Member Posts: 147 Joined: Dec 2013
(15C) Accurate TVM for HP-15C
Note: See post #6 for the latest version (now 40 lines in length). I have left previous posts unedited to avoid causing confusion.

This is an adaptation of the Pioneer's (42S/35S/33S/32Sii/32S) Accurate TVM routine for the HP-15C using Karl Schneider's technique for invoking SOLVE with the routine written as a MISO (multiple-input, single-output) function, using indirect addressing.

001 f LBL E
002 STO(i)
003 RCL 2
004 EEX
005 2
006 ÷
007 ENTER
008 ENTER
009 1
010 +
011 LN
012 X<>Y
013 LSTx
014 1
015 X≠Y
016 -
017 ÷
018 *
019 RCL * 1
020 e^x
021 ENTER
022 RCL * 3
023 X<>Y
024 1
025 -
026 RCL * 4
027 EEX
028 2
029 RCL ÷ 2
030 RCL + 6
031 *
032 +
033 RCL + 5
034 RTN

Usage instructions:

1. Store 4 of the following 5 variables, using appropriate cash flow conventions as follows:
• N STO 1 --- Number of compounding periods
• I STO 2 --- Interest rate (periodic) expressed as a %
• B STO 3 --- Initial Balance or Present Value
• P STO 4 --- Periodic Payment
• F STO 5 --- Future Value
and store the appropriate value (1 for Annuity Due or 0 for Regular Annuity) as
B/E STO 6 --- Begin/End Mode. The default is 0 for regular annuity or End Mode.

2. Store the register number containing the floating variable to the indirect storage register.

3. f SOLVE E

Example from the HP-15C Advanced Functions Handbook-

"Many Pennies (alternatively known as A Penny for Your Thoughts):

A corporation retains Susan as a scientific and engineering consultant at a fee of one penny per second for her thoughts, paid every second of every day for a year.
Rather than distract her with the sounds of pennies dropping, the corporation proposes to deposit them for her into a bank account in which interest accrues at the rate of 11.25 percent per annum compounded every second. At year's end these pennies will accumulate to a sum

total = (payment) X ((1+i/n)^n-1)/(i/n)

where payment = $0.01 = one penny per second, i = 0.1125 = 11.25 percent per annum interest rate, n = 60 X 60 X 24 X 365 = number of seconds in a year. Using her HP-15C, Susan reckons that the total will be$376,877.67. But at year's end the bank account is found to hold $333,783.35 . Is Susan entitled to the$43,094.32 difference?"

• 31,536,000 STO 1
• (11.25/31,536,000) STO 2
• 0 STO 3
• -0.01 STO 4
• 5 STO I
• f SOLVE E

The HP-15C now gives the correct result: \$333,783.35.

Thanks to Thomas Klemm for debugging the above routine.
Edit: The code has been edited to reflect Thomas' suggested changes below.

Jeff Kearns
01-10-2014, 05:31 AM
Post: #2
 Thomas Klemm Senior Member Posts: 1,447 Joined: Dec 2013
RE: Accurate TVM for HP-15C
(01-10-2014 03:36 AM)Jeff_Kearns Wrote:  027 RCL 2
028 EEX
029 2
030 ÷
031 1/x
Any reason for not using:

027 EEX
028 2
029 RCL ÷ 2

Just curios.
01-10-2014, 05:38 AM (This post was last modified: 01-10-2014 05:48 AM by Jeff_Kearns.)
Post: #3
 Jeff_Kearns Member Posts: 147 Joined: Dec 2013
RE: Accurate TVM for HP-15C
(01-10-2014 05:31 AM)Thomas Klemm Wrote:  Any reason for not using:

027 EEX
028 2
029 RCL ÷ 2

Just curios.

Oversight! I note that you 'did' suggest this change in the other thread. I will test it tomorrow and edit the post accordingly (or would that cause an issue with the follow-on posts?).

Jeff
01-16-2014, 09:32 PM
Post: #4
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: Accurate TVM for HP-15C
(01-10-2014 03:36 AM)Jeff_Kearns Wrote:  Edit: The code has been edited to reflect Thomas' suggested changes below.

There's a 1/x too much now. ;-) Obviously a leftover from the original code. Take a look at line 30.

Dieter
01-16-2014, 09:38 PM (This post was last modified: 01-16-2014 09:40 PM by Jeff_Kearns.)
Post: #5
 Jeff_Kearns Member Posts: 147 Joined: Dec 2013
RE: Accurate TVM for HP-15C
Dieter wrote: "There's a 1/x too much now. ;-) Obviously a leftover from the original code. Take a look at line 30."

Fixed! Thanks Dieter.
05-25-2014, 03:03 PM (This post was last modified: 05-25-2014 03:42 PM by Jeff_Kearns.)
Post: #6
 Jeff_Kearns Member Posts: 147 Joined: Dec 2013
RE: Accurate TVM for HP-15C
Most accurate version is now 40 lines:

001 - LBL E
002 - STO (i)
003 - RCL 2
004 - EEX
005 - 2
006 - /
007 - ENTER
008 - ENTER
009 - 1
010 - +
011 - LN
012 - x<>y
013 - LSTx
014 - 1
015 - TEST 6
016 - -
017 - /
018 - x
019 - RCLx 1
020 - ENTER
021 - e^x
022 - RCLx 3
023 - x<>y
024 - 2
025 - /
026 - SINH
027 - LSTx
028 - e^x
029 - x
030 - 2
031 - x
032 - RCLx 4
033 - EEX
034 - 2
035 - RCL/ 2
036 - RCL+ 6
037 - x
038 - +
039 - RCL+ 5
040 - RTN
08-27-2016, 10:07 PM (This post was last modified: 08-27-2016 10:42 PM by Nick.)
Post: #7
 Nick Member Posts: 64 Joined: Aug 2016
RE: (15C) Accurate TVM for HP-15C
UI Mod: 40 step version w/ 12C Layout

Layout (12C): [A: N], [B: I], [C: PV], [D: PMT], [E: FV]

Clear: GSB 2
- Mnemonic: 12C
- Note: You must run Clear to initialize the program before use.

Store: STO {A..E}

Solve: [f] {A..E} or for User Mode simply {A..E}
- (Option) Set X & Y to a range of values to search (slightly faster to run and much slower to key)
- (Option) Don't bother entering anything as most of the time it will work as-is. Use 1 ENTER or -1 ENTER and re-run if SOLVE fails. (faster to key)

Recall: RCL {A..E}

Set End (default): 0 STO 2
Set Begin: 1 STO 2
- Mnemonic: 12C

Code:
01 LBL A 02 RCL MATRIX A 03 GTO 0 04 LBL B 05 RCL MATRIX B 06 GTO 0 07 LBL C 08 RCL MATRIX C 09 GTO 0 10 LBL D 11 RCL MATRIX D 12 GTO 0 13 LBL E 14 RCL MATRIX E 15 LBL 0 16 STO I 17 Rdn 18 SOLVE 1 19 RTN 20 LBL 1 21 STO (i)  22 RCL B  23 EEX  24 2  25 /  26 ENTER  27 ENTER  28 1  29 +  30 LN  31 X<->Y 32 LSTx  33 1  34 TEST 6  35 -  36 /  37 *  38 RCL* A  39 ENTER  40 e^x  41 RCL* C  42 X<->Y 43 2  44 /  45 HYP SIN 46 LSTx  47 e^x  48 *  49 2  50 *  51 RCL* D 52 EEX  53 2  54 RCL/ B  55 RCL+ 2  56 * 57 + 58 RCL+ E  59 RTN 60 LBL 2 61 MATRIX 0 62 1 63 ENTER 64 DIM A 65 DIM B 66 DIM C 67 DIM D 68 DIM E 69 MATRIX 1 70 [CLEAR] SIGMA 71 STO 2 72 RTN

- Uses 1x1 Matricies to treat A..E as direct access registers. This requires R0=1 and R1=1 for A..E to function. This is set via MATRIX 1 in the Initialize/Clear routine. The contents of A..E will not be lost if R0 or R1 are changed, but they must be reset with MATRIX 1 (or manually) to restore direct access.
- The 12C style version in the 15C Advanced Functions Handbook p24-30 [2012] by contrast is 108 steps long.
08-27-2016, 10:34 PM (This post was last modified: 08-27-2016 11:58 PM by Nick.)
Post: #8
 Nick Member Posts: 64 Joined: Aug 2016
RE: (15C) Accurate TVM for HP-15C
Issue:

The 40 step version fails when I = 0 (either by setting it as a value or when searching for I).

Workaround:

Set X & Y = 1 when solving for I (or a similar known range to search)

Set I = (a very small interest rate) to approximate 0% interest problems or solve manually.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)