Post Reply 
PPC Journal V2N6 - TVM i% unknown on HP-65
10-18-2015, 07:40 PM
Post: #21
RE: PPC Journal V2N6 - TVM i% unknown on HP-65
(10-18-2015 01:36 PM)Dieter Wrote:  This is another detail where earlier and later calculators differ. The first business oriented device, the HP80, had its five TVM keys in the order n i PMT PV FV. So did the HP22, as well as this annuity program for the HP65. Later models however used n i PV PMT FV (which seems a bit more logical).

I've not seen this discussed before; you're right Dieter, it is annoying. Having learned finance Fns on the newer models (you know, those 40 years or less), I consistently mess-up when using the HP-80, HP-22 and (my recently acquired) HP-27.

Though HP did stick with their standards, this is a good example of changing a standard when a better (or more logical as you say) idea comes along.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
10-18-2015, 08:11 PM (This post was last modified: 10-19-2015 05:05 PM by Dieter.)
Post: #22
RE: PPC Journal V2N6 - TVM i% unknown on HP-65
(10-18-2015 08:08 AM)AndiGer Wrote:  Tried just now - it works great! End mode 4 iterations, Beg mode 3.
(of course used y^x code 05)

Fine. Once we get rid of the LBL A ... LBL E part there is room for some improvements. The following version quits if the relative error is below 1E–6. It also checks whether the first guess for the interest rate is exactly zero. In this case that's already the result and the program exits. This also avoids a division by i=0 in the first iteration.

Code:
01   LBL     23       Start calculation
02   B       12  
03   RCL 1   34 01    n
04   RCL 3   34 03    PMT
05   x       71  
06   RCL 4   34 04    PV
07   +       61  
08   RCL 5   34 05    FV
09   +       61  
10   RCL 5   34 05   
11   RCL 4   34 04   
12   -       51  
13   RCL 1   34 01   
14   x       71  
15   ÷       81  
16   2       02  
17   x       71       = initial guess for i
18   STO 2   33 02    store i in R2
19   0       44  
20   g x=y?  35 23    i = 0 ?
21   GTO     22       then exit program
22   2       02  
23   LBL     23       start iteration
24   1       01  
25   RCL 2   34 02   
26   1       01  
27   +       61  
28   STO 6   33 06    store q=1+i in R6
29   RCL 1   34 01   
30   CHS     42  
31   g       35  
32   y^x     05  
33   STO 7   33 07    store q^-n in R7
34   RCL 5   34 05   
35   x       71  
36   1       01  
37   RCL 7   34 07   
38   -       51  
39   RCL 3   34 03   
40   x       71  
41   RCL 2   34 02   
42   ÷       81  
43   STO 8   33 08    store pmt·(1-q^-n) / i in R8
44   f       31  
45   TF 1    61       if "begin" mode is set
46   RCL 6   34 06    multiply by (1+i)
47   x       71  
48   +       61  
49   RCL 4   34 04   
50   +       61       = TVM (i, n, PMT, PV, FV)
51   RCL 8   34 08
52   RCL 2   34 02   
53   ÷       81  
54   RCL 3   34 03   
55   RCL 2   34 02   
56   ÷       81  
57   f       31  
58   TF 1    61       if "begin" mode is set
59   RCL 3   34 03    add PMT
60   +       61  
61   RCL 5   34 05   
62   -       51  
63   RCL 7   34 07   
64   x       71  
65   RCL 1   34 01   
66   x       71  
67   RCL 6   34 06   
68   ÷       81  
69   -       51       = -TVM' (i, n, PMT, PV, FV)
70   ÷       81       Δi = -TVM / TVM'
71   STO     33       add Δi to i
72   +       61  
73   2       02  
74   RCL 2   34 02   
75   ÷       81       relative error = Δi / i
76   g       35  
77   ABS     06  
78   EEX     43  
79   CHS     42  
80   6       06  
81   g x≤y?  35 22    is |relative error| ≥ 1E-6 ?
82   GTO     22       then do another iteration
83   1       01
84   LBL     23       exit routine
85   2       02  
86   RCL 2   34 02    recall i
87   EEX     43  
88   2       02  
89   x       71       return i% = i · 100%
90   RTN     24       and quit

I could not check this code on a real HP65, so I hope it does what it is supposed to. ;-)
I also hope I got the key codes right.

EDIT: the original version I posted included a loop counter but had an error. The code above is a corrected version.

BTW, what does the HP65 do if the last command is not a RTN or R/S? Does it simply stop like later calculators? Or does it behave differently? In other words: if the 101st step would be a RTN, can it be omitted so that the code fits?

Dieter
Find all posts by this user
Quote this message in a reply
08-14-2016, 10:57 PM
Post: #23
RE: PPC Journal V2N6 - TVM i% unknown on HP-65
(10-18-2015 08:11 PM)Dieter Wrote:  [quote='AndiGer' pid='44147' dateline='1445155729']
Tried just now - it works great! End mode 4 iterations, Beg mode 3.
(of course used y^x code 05)

I had not seen this issue before. For the HP 35s, is there another way to clear up questions or need to adapt the HP 65 program, or maybe already exists one developed for this purpose?. I very much like to have a numerical example to evaluate the results in my HP 35s.
Find all posts by this user
Quote this message in a reply
08-15-2016, 07:09 PM (This post was last modified: 08-15-2016 07:12 PM by Dieter.)
Post: #24
RE: PPC Journal V2N6 - TVM i% unknown on HP-65
(08-14-2016 10:57 PM)PedroLeiva Wrote:  I had not seen this issue before. For the HP 35s, is there another way to clear up questions or need to adapt the HP 65 program, or maybe already exists one developed for this purpose?.

The 35s does not even need a program. ;-) Since it offers a solver and an equation mode, all you need is the classic TVM equation. Which can be found in the 35s manual, even with some examples: cf. chapter 17-1.

(08-14-2016 10:57 PM)PedroLeiva Wrote:  I very much like to have a numerical example to evaluate the results in my HP 35s.

You can find some numerical examples in the first posts of this thread.
And, as stated, in the 35s manual.

You should also take a look at the General Software Library and search for "Accurate TVM". There are programs for various calculators where ln(1+x) and e^x–1 functions are implemented which leads to more accurate results for small interest rates.

Dieter
Find all posts by this user
Quote this message in a reply
08-15-2016, 07:43 PM
Post: #25
RE: PPC Journal V2N6 - TVM i% unknown on HP-65
(08-15-2016 07:09 PM)Dieter Wrote:  
(08-14-2016 10:57 PM)PedroLeiva Wrote:  I had not seen this issue before. For the HP 35s, is there another way to clear up questions or need to adapt the HP 65 program, or maybe already exists one developed for this purpose?.

The 35s does not even need a program. ;-) Since it offers a solver and an equation mode, all you need is the classic TVM equation. Which can be found in the 35s manual, even with some examples: cf. chapter 17-1.

You can find some numerical examples in the first posts of this thread.
And, as stated, in the 35s manual.

You should also take a look at the General Software Library and search for "Accurate TVM". There are programs for various calculators where ln(1+x) and e^x–1 functions are implemented which leads to more accurate results for small interest rates.

Dieter
TWVM, I will take a look of both: General Software Library and Manual
Pedro
Find all posts by this user
Quote this message in a reply
09-11-2017, 05:23 PM
Post: #26
RE: PPC Journal V2N6 - TVM i% unknown on HP-65
Sorry I get back to this old thread (some part already no more available).

The program code Dieter suggested in post #11 may work if we just omit LBL B.
As I just read in Key 65 Key Note V1N1 (found on TOS) this is possible!
Because if LBL B is not found the calculator will start execution at top of memory.
Just to finally mention ;-)
Andi
Find all posts by this user
Quote this message in a reply
09-13-2017, 07:32 PM (This post was last modified: 09-13-2017 08:21 PM by Dieter.)
Post: #27
RE: PPC Journal V2N6 - TVM i% unknown on HP-65
(09-11-2017 05:23 PM)AndiGer Wrote:  The program code Dieter suggested in post #11 may work if we just omit LBL B.
As I just read in Key 65 Key Note V1N1 (found on TOS) this is possible!
Because if LBL B is not found the calculator will start execution at top of memory.
Just to finally mention ;-)

Wow, that's a great find! I wonder if there is any other calculator that does not throw an error if a nonexisting label is called and instead behaves this way with starting at the memory top.

And indeed this seems to work. For the record, here is the complete listing (with a slight modification in the iteration's exit condition).

Code:
 01  RCL 1  34 01
 02  RCL 3  34 03
 03  x      71
 04  RCL 4  34 04
 05  +      61
 06  RCL 5  34 05
 07  +      61
 08  RCL 5  34 05
 09  RCL 4  34 04
 10  -      51
 11  RCL 1  34 01
 12  x      71
 13  ÷      81
 14  2      02
 15  x      71
 16  STO 2  33 02
 17  LBL    23
 18  1      01
 19  g      35
 20  ABS    06
 21  EEX    43
 22  CHS    42
 23  7      07
 24  g x>y? 35 24
 25  GTO    22
 26  2      02
 27  RCL 2  34 02
 28  1      01
 29  +      61
 30  STO 6  33 06
 31  RCL 1  34 01
 32  CHS    42
 33  g      35
 34  y^x    05
 35  STO 7  33 07
 36  RCL 5  34 05
 37  x      71
 38  1      01
 39  RCL 7  34 07
 40  -      51
 41  RCL 3  34 03
 42  x      71
 43  RCL 2  34 02
 44  ÷      81
 45  STO 8  33 08
 46  f      31
 47  TF 1   61
 48  RCL 6  34 06
 49  x      71
 50  +      61
 51  RCL 4  34 04
 52  +      61
 53  RCL 8  34 08
 54  RCL 2  34 02
 55  ÷      81
 56  RCL 3  34 03
 57  RCL 2  34 02
 58  ÷      81
 59  f      31
 60  TF 1   61
 61  RCL 3  34 03
 62  +      61
 63  RCL 5  34 05
 64  -      51
 65  RCL 7  34 07
 66  x      71
 67  RCL 1  34 01
 68  x      71
 69  RCL 6  34 06
 70  ÷      81
 71  -      51
 72  ÷      81
 73  STO    33
 74  +      61
 75  2      02
 76  GTO    22
 77  1      01
 78  LBL    23
 79  2      02
 80  RCL 2  34 02
 81  EEX    43
 82  2      02
 83  x      71
 84  RTN    24
 85  LBL    23
 86  A      11
 87  STO 1  33 01
 88  RTN    24
 89  LBL    23
 90  C      13
 91  STO 3  33 03
 92  RTN    24
 93  LBL    23
 94  D      14
 95  STO 4  33 04
 96  RTN    24
 97  LBL    23
 98  E      15
 99  STO 5  33 05
100  RTN    24

Example (assuming flag 1 is clear):

n = 5  [ A ]
PMT = 500  [ C ]
PV = 0  [ D ]
FV = -3000  [ E ]
[ B ] => i = 9,128%

With flag 1 set the result is 6,140%

Please also note the version in post #22.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 




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