PPC Journal V2N6 - TVM i% unknown on HP-65 - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: HP-65/67/97 Software Library (/forum-12.html) +--- Thread: PPC Journal V2N6 - TVM i% unknown on HP-65 (/thread-4937.html) Pages: 1 2 |
PPC Journal V2N6 - TVM i% unknown on HP-65 - AndiGer - 10-12-2015 04:48 PM Found an interesting program on Gene Wright's homepage on solving TVM with I% unknown to run on a 65. http://www.rskey.org/gene/calcgene/ann65i.htm Unfortunately the program does not do what is promised. The description is incorrect in the meaning that it will not show 0,00 after entering N, PMT, PV, FV but just the entered value (I% known does). Statement 63 will give key code 33 (STO not RCL). And another thing: If I press B the programm never terminates. Guess it should be the first statement so that RTN stops the calculation. Anbody out there who still owns PPC Journal V2N6 p. 14 and 15 or a copy of it and can give the answer where is the problem in the given code? Thanx Andi RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Gene - 10-12-2015 09:24 PM Sorry for the delay. Here are the relevant two pages. I can't do the checking at the moment. HP 65 program listing RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - SlideRule - 10-15-2015 12:35 AM Yes, there are differences in the transposed & the original program listings. In short, a line of code is missing between lines 47 & 48; 47...81........./ .......34 01....RCL 1 48...32.........f-1 AND a miscode at line 72 (73 w inserted code); 72...35 22...g X<>Y? was interpreted as 72...35 22...g X<=Y? rather than 72...35 21...g X<>Y? kinda like the STO RCL code transpose mentioned earlier. As far as the LBL's returning 0, only claimed for the 'other' prgm, not this one {sorry} Hope this helps! BEST! SlideRule RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Dieter - 10-15-2015 01:21 PM (10-15-2015 12:35 AM)SlideRule Wrote: In short, a line of code is missing between lines 47 & 48 In Gene's listing it's actually between line 46 and 47. But the first two lines (LBL B) are missing, so after adding these it should be between line 48 and 49: Code: 48 81 / (10-15-2015 12:35 AM)SlideRule Wrote: AND a miscode at line 72 (73 w inserted code); No, there is no error at this point. The correct instruction is X≤Y?, or key code 35 22. Here the original listing is wrong! The program finds an iterative solution for the interest rate in R2, and right before this command it adds a correction term (ST0+2) and checks whether its absolute value is sufficiently small. If not ((1E–6 ≤ |correction| which means |correction| ≥ 1E–6), it jumps back and does another iteration. If the X≤Y? test is replaced with X≠Y? the program will almost certainly loop forever ...unless the applied correction term happens to be exactly 1E–6. So yes, the X≤Y? test in Gene's transscription is correct. BTW Gene, maybe you should repair the formatting of this code on rskey.org from line 71ff. And in both HP65 annuity programs the first two lines are missing (LBL B resp. LBL A). I tried this program on an HP41 and in some cases it converged to a solution, in others it didn't. Maybe I got the input values wrong, possibly with wrong signs. At least I did not get the results I expected. Can someone provide a sample problem for this program? Dieter RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - SlideRule - 10-15-2015 02:51 PM Dieter Thanks for the more intense review. My post was a first casual review of ... 1- validate a problem(s) 2- locate possible origin(s) 3- NOT suggest a solution(s) ... since I did NOT author any of the source material. I agree, a composite-redacted version should be published w/ ALL typos, omissions, etc reaccomplished. Again, thanks for the follow-up. BEST! SlideRule RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - SlideRule - 10-15-2015 04:48 PM [/color] (10-12-2015 09:24 PM)Gene Wrote: HP 65 program listing My re-type of the ORIGINAL 65 program code. My redactions are in RED [attachment=2668] Maybe a basis for a clear/clean code? BEST! SlideRule RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - AndiGer - 10-15-2015 04:54 PM First of all: Thank Gene for the fast publishing of the original document pages. I would never ever have found where is the problem of the missing statement (RCL 1) without that. Also thanks to you others for reviewing and discussing that topic. gx<=y to compare with E-6 was clear to me (although the original document gives gx<>y). It was also clear to me to add the missing LBL B at the beginning. I just now ran the program only with basic values. The result given was correct. N=5 PMT=500 (Ordinary Annuity - "End") PV=0 FV=-3000 Result I%=9,12806 Andi RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - SlideRule - 10-15-2015 06:52 PM (10-15-2015 04:54 PM)AndiGer Wrote: First of all: Thank Gene for the fast publishing of the original document pages.My second atempt at a CLEAN program listing. [attachment=2670] BEST! SlideRule RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Dieter - 10-15-2015 07:28 PM (10-15-2015 04:54 PM)AndiGer Wrote: I just now ran the program only with basic values. The result given was correct. Fine. How many iterations were required? I did a quick and dirty test on an HP41 and convergence was quite slow. Did the program also return the correct value for BEG mode (flag 1 set)? This should yield 6,14024%. I also tried a different algorithm with a usual Newton iteration with quadratic convergence, and the result was returned after 4 resp. 3 iterations. BTW, does this program use the same sign convention for PV, PMT and FV as later HPs or is it different in this regard? Dieter RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - AndiGer - 10-16-2015 04:52 PM Running with flag 1 set (begin mode) yields 6.14021. Nearly correct ;-). Needs 11 iterations if I counted correctly. Running in end mode with my given values needs 3 iterations. Andi RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Dieter - 10-16-2015 06:39 PM (10-16-2015 04:52 PM)AndiGer Wrote: Running with flag 1 set (begin mode) yields 6.14021. Nearly correct ;-). Yes, that's what I also noticed: End mode works fine, but in Begin mode convergence is very slow, comparable to simple bisection. There must be something wrong with the program. Maybe someone can take a closer look. In the meantime I tried a different approach. Since I do not own an HP65 maybe someone else may try this code. IMPORTANT: all data is entered according to the sign convention of later HP calculators! Code: 01 LBL This version also handles the case that i% is zero (or nearly so). The iteration exits if the last correction term (or i itself) is less than 5 E–7. Your example in Begin mode now requires just three iterations. Dieter RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - SlideRule - 10-16-2015 10:13 PM (10-16-2015 06:39 PM)Dieter Wrote: ... Since I do not own an HP65 maybe someone else may try this code... these two lines are problematic for the 100 steps on my HP-65. I'll try the coding on another model. BEST! SlideRule RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Dieter - 10-17-2015 05:51 AM (10-16-2015 10:13 PM)SlideRule Wrote: these two lines are problematic for the 100 steps on my HP-65. I'll try the coding on another model. Arrghhh... I forgot that on the 65 all labels require two steps... #-\ I'll see if I can save two so that it all fits in 100 steps. For the time being you may omit the LBL E part and store FV manually in R5. Or remove the first steps (LBL B) and run the program with RTN R/S. Dieter RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - AndiGer - 10-17-2015 10:47 AM Dieter, all, I always omit the statements after Dieter's step 85, i.e. code for LBL A, LBL C, LBL D, LBL E but manually store the required values in registers 1, 3, 4 and 5. That's what the code in those labels simply does. This way you can save several steps. The program could even have several more steps. I will try Dieter's modified code on my 65 when I find some time. Andi RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Thomas Klemm - 10-17-2015 01:22 PM (10-16-2015 06:39 PM)Dieter Wrote: Since I do not own an HP65 maybe someone else may try this code. There's a HP-65 Emultator. Cheers Thomas RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - SlideRule - 10-17-2015 01:56 PM (10-17-2015 10:47 AM)AndiGer Wrote: ... omit the ... code for LBL A, LBL C, LBL D, LBL E but manually store the required values in registers 1, 3, 4 and 5 ... see attached [attachment=2674] hope I'm typo free BEST! SlideRule RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Dieter - 10-17-2015 08:07 PM (10-17-2015 01:56 PM)SlideRule Wrote: see attached Ah, my experimental program. ;-) There is an error in the keycode of the y^x command. But, more important, the remark between step 4 and 5 in the user instructions was taken from the original PPC version, while my program uses the same sign convention as later HPs, i.e. PV, PMT and FV may be positive or negative. That's why there is a minus instead of a plus in the initial guess calculation. Sure, all the stuff starting at LBL A can be removed if the input values are stored directly in R1...R5. The idea was – like in the original program – that the keys of the second annuity program (the one that solves for the other variables) are mirrored so that the user only has to load another card while the A...E keys do the same as before. If this part is removed the code can be improved in several ways. For instance the program may exit if the initial guess is exactly zero (in this case that's the exact solution), or the program may check the relative instead of the absolute error after each iteration. Dieter RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - AndiGer - 10-18-2015 08:08 AM (10-17-2015 08:07 PM)Dieter Wrote: Sure, all the stuff starting at LBL A can be removed if the input values are stored directly in R1...R5. The idea was – like in the original program – that the keys of the second annuity program (the one that solves for the other variables) are mirrored so that the user only has to load another card while the A...E keys do the same as before. ... and the keys to behave like they are used on HP business calculators (HP-22, HP-10(b), HP-17(b), ...) Edit: Tried just now - it works great! End mode 4 iterations, Beg mode 3. (of course used y^x code 05) Andi RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - Dieter - 10-18-2015 01:36 PM (10-18-2015 08:08 AM)AndiGer Wrote: ... and the keys to behave like they are used on HP business calculators (HP-22, HP-10(b), HP-17(b), ...) 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). This still is the standard today. Dieter RE: PPC Journal V2N6 - TVM i% unknown on HP-65 - TASP - 10-18-2015 05:34 PM Don't want to derail the thread, but not worth it's own topic: before the HP80, were there any desk top machines with the " n i PMT PV FV " keys and the random input of the variables ?? |