01-10-2014, 03:36 AM
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:
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?"
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
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
- 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