Adapting 'Accurate' TVM routine on HP-15C (and HP-34C) using MISO Technique
|
01-05-2014, 01:06 AM
(This post was last modified: 01-23-2014 12:53 AM by Jeff_Kearns.)
Post: #1
|
|||
|
|||
Adapting 'Accurate' TVM routine on HP-15C (and HP-34C) using MISO Technique
EDIT: The following listing has been edited to reflect feedback from forum members and match the listing in the software library here.
This is (was) my first post on the 'new' forum. I am trying to adapt the Accurate TVM routine for Pioneers to the HP-15C using Karl Schneider's technique for invoking SOLVE with the routine written as a MISO (multiple-input, single-output) function, with indirect addressing. In this case, there are 6 variables (5 knowns). Karl's article can be found here. Unfortunately I cannot get it to work and I have exhausted my non-programmer's efforts to debug! My HP-15C adaptation of the code is as follows (apologies for the formatting): 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 When I try solving for the Present Value (or initial balance 'B') with the following values for a 4 year car loan, at 2.9% annual interest, and $ -658.39 monthly payment: N = 48 STO 1 I = .2417 (2.9% annual) STO 2 B = STO 3 (in this case the variable I want to solve for, so 3 STO I) P = -658.39 STO 4 F = 0 STO 5 E = 0 STO 6 The answer in register 3, should be B = 29,804.68. Instead I get B = -214,521.14 Can anyone help me troubleshoot this routine? If I can have a MISO solver routine for the TVM equation in my 15C, it will be very useful indeed. Can then leave the financial calc at home. Regards, Jeff Kearns (Ottawa) |
|||
01-05-2014, 02:10 AM
(This post was last modified: 01-05-2014 02:22 AM by Thomas Klemm.)
Post: #2
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-05-2014 01:06 AM)Jeff_Kearns Wrote: Can anyone help me troubleshoot this routine? The problem are these two lines: 022 RCL * 3 023 LSTx The RCL multiplication doesn't change LASTx. I've changed that to: 021 ENTER 022 RCL * 3 023 X<>Y In addition to that I also replaced 100 by EEX 2. Thus saving two instructions: 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 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 Cheers Thomas Edit: Lines 027 - 031 could be improved a little as well. |
|||
01-05-2014, 02:18 AM
Post: #3
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
Thomas - Thanks! It now works beautifully.
Quote:The problem are these two lines: Why then, does the routine work on Pioneers, but not on the 15C? In any event - the 15 C is now a fully functional (for most of my needs anyway) financial calculator with plenty of room for other programs. Jeff K |
|||
01-05-2014, 02:33 AM
(This post was last modified: 01-05-2014 02:53 AM by Thomas Klemm.)
Post: #4
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-05-2014 02:18 AM)Jeff_Kearns Wrote: Thomas - Thanks! It now works beautifully.Glad, I could help. Quote:Why then, does the routine work on Pioneers, but not on the 15C?No idea. Maybe they missed to implement that in the 15C and added that behavior later? I must admit I was rather surprised. I wasn't aware of this difference. RCL isn't listed here: Cheers Thomas |
|||
01-05-2014, 04:36 AM
(This post was last modified: 01-05-2014 04:42 AM by Jeff_Kearns.)
Post: #5
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
LASTx function in Pioneer models 32sii/33s/35s:
The recall arithmetic sequence * RCL + variable stores x in LASTx and * RCL variable + stores the recalled number in LASTx. LSTx_small.jpg (Size: 2.27 KB / Downloads: 416) Jeff K |
|||
01-05-2014, 04:53 AM
Post: #6
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
Jeff,
The thumbnail you're showing isn't readable. Please improve. d:-/ |
|||
01-05-2014, 05:03 AM
(This post was last modified: 01-05-2014 05:04 AM by Jeff_Kearns.)
Post: #7
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
Walter,
I tried editing it (it has to be smaller than 200 Kb) but failed. I will try again tomorrow. It is simply the listing from annex B in the 35s manual on LASTx functions. The same list is in the 32sii manual, and presumably the 32s also. My apologies for the unreadable attachment - it is not even a thumbnail. Will correct... Regards, Jeff Kearns |
|||
01-05-2014, 05:28 AM
(This post was last modified: 01-05-2014 05:46 AM by Thomas Klemm.)
Post: #8
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-05-2014 04:36 AM)Jeff_Kearns Wrote: The recall arithmetic sequence * RCL + variable stores x in LASTx and * RCL variable + stores the recalled number in LASTx.I think it should be read as: The recall arithmetic sequence X RCL + variable stores x in LASTx and X RCL variable + stores the recalled number in LASTx. HP 35s scientific calculator user's guide HP 32SII RPN Scientific Calculator Owner’s Manual It appears somebody tried to improve the manual for the HP 35s and failed. At least they fixed the typo: riot vs. not Cheers Thomas |
|||
01-05-2014, 06:24 AM
Post: #9
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
The 34S stores Last X when doing recall arithmetic operations I think.
Prof Kahan has some insightful things to say about financial calculations in one of his papers. Sorry no reference. He basically gives some really pathological examples which the 12C can do but few others manage. - Pauli |
|||
01-05-2014, 08:47 AM
(This post was last modified: 01-05-2014 05:53 PM by Thomas Klemm.)
Post: #10
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-05-2014 06:24 AM)Paul Dale Wrote: Sorry no reference.From Mathematics Written in Sand: A Penny for your Thoughts. Enter data: n := 60*60*24*365 = 31,536,000 sec. per year. i := 10/n = 0.000 000 317 097 9198 % per sec. PV := 0 PMT := -0.01 = one cent per sec. to the bank. Calculators FV displayed ~~~~~~~~~~~ ~~~~~~~~~~~~ 27, 92, 37, 38, 12 331,667.0067 15 331,667.0070 For instance, recalculating i displays this: Calculators press [i] and see ... ~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ 27, 92, 37, 38 0.000 000 317100 12 0.000 000 31974 15 0.000 000 317098 Yield from a Risky Investment. For an investment of -PV := $ 35,000,000 now, investors are promised n := 100 equal monthly installments of an amount PMT yet to be agreed upon, but between $ 640,000 and $ 1,000,000 , plus a final payment at the 100th month of FV := $ 100,000,000 . How does the yield i , reckoned in % per month, vary with PMT ? PMT true i % i on the HP-15C ~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~~~~~~ $ 640,000 2.314053 2.314053 650,000 2.335758 2.335758 660,000 2.357528 2.357528 800,000 2.669065 2.669065 1,000,000 3.135506 3.135506 Cheers Thomas |
|||
01-05-2014, 04:55 PM
(This post was last modified: 01-05-2014 05:05 PM by Jeff_Kearns.)
Post: #11
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
Thomas,
Where did you get your figures for the 15C? They do not match my results. Quote:A Penny for your Thoughts.As for the A Penny for your Thoughts example, both the 15C 'Classic' and LE (with the above TVM routine) give FV = 331,667,0070 - accurate to 9 significant digits and off by -0.000 000 090%. By comparison, the 32sii and 35s both give FV= 331,667.0067. Neither the 15C LE nor the 15C Classic are capable of calculating the i%. The 15C LE flashes 3.015... E 94 and the Classic went on for 20 minutes before I stopped it. In the case of the Yield from a Risky Investment example, both the 15C LE and Classic models gave the correct true i% (although the correct numbers will flash in the LE display if one does not provide a suitable initial guess for i% in register 2). The 32sii gives the correct result for i% in all cases. The 'riot' vs 'not' typo in the 32sii manual only seems to have crept in in edition 5. Edition 4 is correct. Jeff |
|||
01-05-2014, 05:43 PM
Post: #12
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-05-2014 04:55 PM)Jeff_Kearns Wrote: Where did you get your figures for the 15C? They do not match my results. Agreed: I had for some reason E (register 6) set to 1. Quote:Neither the 15C LE nor the 15C Classic are capable of calculating the i%. The 15C LE flashes 3.015... E 94 and the Classic went on for 20 minutes before I stopped it. Did you set I = 2? I used 3e-7 and 4e-7 as initial guesses and now I get: 3.170979158e-7 Quote:In the case of the Yield from a Risky Investment example, both the 15C LE and Classic models gave the correct true i% (although the correct numbers will flash in the LE display if one does not provide a suitable initial guess for i% in register 2). The 32sii gives the correct result for i% in all cases. Darn. Here I must have used FV := $ 1,000,000 instead of FV := $ 100,000,000. Thanks for checking. I'll adjust my post accordingly. Quote:The 'riot' vs 'not' typo in the 32sii manual only seems to have crept in in edition 5. Edition 4 is correct.Maybe they had to scan the document and used an OCR-program? Best regards Thomas |
|||
01-05-2014, 06:27 PM
Post: #13
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
Now it works! Thanks Thomas.
Jeff |
|||
01-06-2014, 12:27 AM
Post: #14
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
You could add this useful program to the General Software Library.
It's difficult to find it in a random thread. Kind regards Thomas |
|||
01-06-2014, 01:38 AM
Post: #15
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
I will add it. Interestingly, I was unable to locate the thread using Google: 'accurate tvm 15c site:hpmuseum.org', or any variant thereof. It does show results for other similar routines in the 'old' forum.
Jeff |
|||
01-10-2014, 02:46 AM
(This post was last modified: 01-10-2014 04:22 AM by Jeff_Kearns.)
Post: #16
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-06-2014 12:27 AM)Thomas Klemm Wrote: You could add this useful program to the General Software Library. I now have another program to add to the library, thanks to Katie Wasserman: The same TVM program adapted for the HP-34C. Since the 34C does not have Recall Arithmetic, one has to use a workaround as follows: 1) Replace RCL * 1 with roll-up STO 7 roll-down RCL 1 * RCL 7 roll-down 2) Replace RCL * 3 with roll-up STO 7 roll-down RCL 3 * RCL 7 roll-down 3) Replace RCL * 4 with roll-up STO 7 roll-down RCL 4 * RCL 7 roll-down 4) Replace RCL + 6 with roll-up STO 7 roll-down RCL 6 + RCL 7 roll-down 5) Replace RCL + 5 with roll-up STO 7 roll-down RCL 5 + RCL 7 roll-down The above obviously adds 30 lines of code for a total of 66 lines on the 34C, but once you get the program off and running, you feel like Cap't Zener watching "all them blinkin' lights" solve any of the variables in the TVM equation (albeit a little more slowly than the HP-15C LE does... but that's OK)! Where is Norm anyway??? He may not have much time for finance-types ;-) but he would likely enjoy having this program on his 'calculateur-de-choix'. Jeff |
|||
01-10-2014, 05:08 AM
Post: #17
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-10-2014 02:46 AM)Jeff_Kearns Wrote: Since the 34C does not have Recall Arithmetic, one has to use a workaround as follows: You don't have to do that. A simple RCL 1, * will work. The T-register never contains values that we have to save in register 7. Similar in all other cases. But if it adds to the blinking... Cheers Thomas |
|||
01-10-2014, 10:50 PM
Post: #18
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-10-2014 05:08 AM)Thomas Klemm Wrote: You don't have to do that. A simple RCL 1, * will work. The T-register never contains values that we have to save in register 7. Similar in all other cases. But if it adds to the blinking... You may be correct insofar as the first RCL * 1 substitution is concerned because there are only 2 numbers on the stack, but I tried that with the others and the program doesn't work. There must be some subtle stack lift thing going on that recall arithmetic avoids in the subsequent substitutions. I have not thoroughly investigated the issue. Have you tried the program with your suggested change; RCL OPERATION nn to RCL nn OPERATION? Regards, Jeff |
|||
01-11-2014, 12:14 AM
Post: #19
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
(01-10-2014 10:50 PM)Jeff_Kearns Wrote:(01-10-2014 05:08 AM)Thomas Klemm Wrote: You don't have to do that. A simple RCL 1, * will work.... Thomas is right. I tried the program on a HP35s, both with and without RCL-arithmetics. There is just one pitfall you have to watch: that's line 021/022 in Thomas' code. Without RCL-arithmetics another ENTER has to be added there: With RCL-arithmetics: ENTER RCL* 3 X<>Y ...and without: ENTER ENTER RCL 3 * X<>Y The additional ENTER here is required to save the content of Y. Otherwise all occurences of RCL-arithmetics indeed can be replaced by a simple RCL n followed by the respective operation. Dieter |
|||
01-11-2014, 12:27 AM
Post: #20
|
|||
|
|||
RE: Adapting 'Accurate' TVM routine on HP-15C using MISO Technique
Thanks Dieter. I will test and verify on the 34C and revise the code in the software section accordingly. It will save a number of steps!
Regards, Jeff |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)