The Museum of HP Calculators

HP Forum Archive 17

 alternative cos(x) and tan(x) [HP-33S]Message #1 Posted by Gerson W. Barbosa on 23 July 2007, 9:36 p.m. Each of the following programs takes up only one label and will always give at least 11 correct digits for arguments in degrees ( -999,999,999,909 <= x <= 999,999,999,999 ). Gerson. ```L0001 LBL L L0002 x<>y L0003 STO A L0004 x<>y L0005 +/- L0006 90 L0007 + L0008 360 L0009 RMDR L0010 STO B L0011 90 L0012 INT/ L0013 STO C L0014 ENTER L0015 ENTER L0016 2 L0017 INT/ L0018 - L0019 180 L0020 * L0021 RCL- B L0022 -1 L0023 RCL C L0024 ENTER L0025 x! L0026 + L0027 y^x L0028 * L0029 STO B L0030 x^2 L0031 ENTER L0032 ENTER L0033 ENTER L0034 2.0934E-26 L0035 * L0036 4.47566E-20 L0037 - L0038 * L0039 5.55391606E-14 L0040 + L0041 * L0042 3.28183761372E-08 L0043 - L0044 * L0045 5.81776417331E-03 L0046 + L0047 RCL* B L0048 ENTER L0049 x^2 L0050 4 L0051 * L0052 +/- L0053 3 L0054 + L0055 * L0056 RCL A L0057 x<>y L0058 RTN LN=330 CK=AE03 M0001 LBL M M0002 DEG M0003 x<>y M0004 STO D M0005 x<>y M0006 SIN M0007 LASTx M0008 XEQ L M0009 / M0010 RCL D M0011 x<>y M0012 RTN LN=36 CK=3737 89.9999999 XEQ L -> 1.74532925199E-9 89.9999999 COS -> 1.74532000000E-9 actual -> 1.74532925199433E-9 89.9999999 XEQ M -> 572,957,795.132 89.9999999 TAN -> 572,960,832.397 actual -> 572,957,795.1308232 -5555 XEQ L -> -9.06307787035E-1 -5555 COS -> -9.06307787037E-1 actual -> -9.06307787036650E-1 ```

 Re: alternative cos(x) and tan(x) [HP-33S]Message #2 Posted by Les Wright on 23 July 2007, 10:59 p.m.,in response to message #1 by Gerson W. Barbosa Thanks Gerson for sharing yet another version of your minimax polynomial approximations of some of the trigonometric functions. For fussbudgets like me, this will be very useful, and I will enter them in my HP35S (the porting should be easy) when I get it. I am actually more troubled by the persistence of the cosine bug than the inconvenient entry of hex numbers everyone seems so fussed about. The persistence of the digit loss for arguments approaching 90 degrees has accuracy implications for the sine of very small angles, the tangent function, complex number math, and of course rectangular-polar conversions. FWIW, can someone with a 35S compute the cosine for 89.99, 89.999, 89.9999, and 89.99999, etc., degrees and let us all know? Les

 Re: alternative cos(x) and tan(x) [HP-33S]Message #3 Posted by sjthomas on 23 July 2007, 11:13 p.m.,in response to message #2 by Les Wright Quote: FWIW, can someone with a 35S compute the cosine for 89.99, 89.999, 89.9999, and 89.99999, etc., degrees cos(89.99) = 1.74532924306 E-4 cos(89.999) = 1.74532925091 E-5 cos(89.9999) = 1.74532925 E-6 cos(89.99999) = 1.7453292 E-7 cos(89.999999) = 1.745329 E-8 cos(89.9999999) = 1.74532 E-9 cos(89.99999999) = 1.74532925199 E-10 cos(89.999999999) = 1.74532925199 E-11 cos(89.9999999999) = 1.74532925199 E-12 cos(89.99999999999) = 1.74532925199 E-12 cos(89.999999999999) = 1.74532925199 E-12 . . . Edited: 23 July 2007, 11:14 p.m.

 Re: alternative cos(x) and tan(x) [HP-33S]Message #4 Posted by Les Wright on 24 July 2007, 12:48 a.m.,in response to message #3 by sjthomas Thanks! Yep, the cosine bug has survived unchanged. I am actually intrigued that when one gets to 89.99999999, full 12-digit accuracy in the result returns. Weird! I am sure someone once explained the cause of this bug. Les Edited: 24 July 2007, 5:35 a.m.

 Re: alternative cos(x) and tan(x) [HP-33S]Message #5 Posted by Gene Wright on 24 July 2007, 11:29 a.m.,in response to message #4 by Les Wright Hi Les (and all). The 35s review at the hpcc.org site stated that the COS bug was still there. This was available the day the 35s was announced.

 Re: alternative cos(x) and tan(x) [HP-33S]Message #6 Posted by Gerson W. Barbosa on 24 July 2007, 10:55 a.m.,in response to message #2 by Les Wright Quote: I will enter them in my HP35S (the porting should be easy) when I get it. Hello Les, I think it will run with no modification on the HP-35s. But it will require three keystrokes to access the function, by what I've read: [XEQ] [L] [ENTER], for instance, instead of the more convenient [XEQ] [COS] on the HP-33s. Best regards, Gerson.

 Re: alternative cos(x) and tan(x) [HP-33S]Message #7 Posted by Les Wright on 25 July 2007, 5:35 a.m.,in response to message #6 by Gerson W. Barbosa Gerson, Your routines are very fast. Say what you like about the now obsolete 33S, but it does run keystroke programs with lightning quickness. I understand that in many cases the 35S may actually be slower! I also like how you preserve the contents of the Y register for subsequent calculations. Unfortunately the routines don't keep the entire stack in its original state, but this is a nice touch. One problem about RPN programs is they make a mess of the stack sometimes, unlike the internal routines. RPL programs tend not to do this, unless you want them too. Les

 Re: alternative cos(x) and tan(x) [HP-33S]Message #8 Posted by Gerson W. Barbosa on 27 July 2007, 2:22 p.m.,in response to message #7 by Les Wright Hello Les, Quote: Your routines are very fast. Say what you like about the now obsolete 33S, but it does run keystroke programs with lightning quickness. I understand that in many cases the 35S may actually be slower! Too bad they don't run fast enough on the 35s: about 1.5 seconds. They appear to run 10 times faster on the 33s (no timing so far). Also, [XEG] [COS] [ENTER] is very inconvenient. And having to press [>] to see the exponent is pretty cumbersome. Didn't they realize the exponent is much more important than the least significant digits? I prefer ALL mode, not that I don't care about all those digits, but because I don't like integers being displayed will all those zeros. I am very inclined to getting rid of this 35s and getting another obsolete 33s... Regards, Gerson.

Go back to the main exhibit hall