The Museum of HP Calculators

HP Forum Archive 06

 HP-12C Trigs [Final]Message #1 Posted by Ex-PPC member on 18 Oct 2001, 5:29 a.m. Chris Randle wrote: "Just to whet your appetite, the sine routine is 29 steps and the article goes in to great detail (six A5 pages) over the implementation. I believe it's a preliminary article to implementing all scientific funtions on the 12C in case it becomes the final bastion of RPN" First of all, I really, really appreciate your kindness in trying to help with my question, but again, I have no problem at all implementing a sine routine on the 12C, nor do I need six A5 pages to tell how it's done, nor can it "whet my appetite" to know how it's done in 29 steps. Matter of fact, my actual implementation of that sine function is just 18 bytes, far shorter than the 29 bytes you mention. To use 6 pages to describe a 29-byte sine function would be considered a blatant "filler" in the old PPC Journal times, so I hope for the benefit of its readers that the article goes deeper into some other worthy aspects of the question. Anyway, implementing a sine routine is simple to the point of being trivial. What troubles me, my actual question, and I'll repeat it here for the last time, is: "Can anyone point me to (show, produce, etc) an HP-12C program that implements ALL 6 trigonometric functions (sine, cosine, tangent, AND THEIR INVERSES) in a SINGLE program, 99 steps or less ?" That's it. No use for a 6-page article that shows how to implement a sine function in 29 steps. It's either all 6 functions in 99 steps (or less) on the 12C or simply you aren't answering my question at all. Please don't get me wrong, I am *really* thankful for the well-meant answers. It's just that they sidestep the original question and we don't make any progress. By now it's clear to me that the HP RPN programming comunity cannot cope or does not want to cope with this topic that I thought was very old hat, common knowledge and now see that actually it's an unconquered challenged, at least for this forum's participants. Well, perhaps this is for the better and I'll succeed on my own. Thanks again to everyone.

 Re: HP-12C Trigs [Final] - An opinionMessage #2 Posted by Andrés C. Rodríguez (Argentina) on 18 Oct 2001, 8:28 a.m.,in response to message #1 by Ex-PPC member Dear Ex-PPC member: I am just a frequent visitor or participant here, certainly not a moderator nor more than another peer. I would like to say to you (it would be nice to state your name, but it is your choice to be nice or not) that I personally think the style of your message is not the proper one here. For the last years this forum has been a place where people who appreciate the features of HP calcs share their ideas, problems, and knowledge; trying to enjoy from helping others, learning from others, and exchange views with people from other professions, countries, ages, etc., but with a common interest. There is nothing wrong with someone describing his/her particular solution to a problem; I appreciate the effort of writing many pages describing a solution clearly, so others may benefit from the underlying principles. It does not matter if the solution is the "best", or optimal in execution time, memory usage, the "first" to arrive, or else. Indeed, I think it is very difficult to say some solution is "better" than other. Many of us have submitted incomplete, suboptimal or even wrong postings, without causing any damage. Most of the time, we take the care to state "this is just my opinion", "no warranties", etc. It is incredible how much you can enjoy, learn and create from such "imperfect" materials. Except in particlar cases where the curator declares a "contest" to challenge others in a fair manner, the spirit here is cooperative rather than competitive; and always respectful for others' submissions. I think anyone who don't like this climate may just use his/her time in more profitable activities from that paricular point of view. Again, it is just a personal opinion.

 Re: HP-12C Trigs [Final] - I supportMessage #3 Posted by Vieira, Luiz C. (Brazil) on 18 Oct 2001, 10:07 a.m.,in response to message #2 by Andrés C. Rodríguez (Argentina) I spend most of the time I have to write in here by selecting words, sentences, ideas and concepts so I will not hurt the spirit fairly (and a lot well) described by Mr. Rodríguez (great contributor). And I believe Mr. Rodrígues’ is right. I’m an uninvited guess, so I should not mess around. As I am trying to do right now. I have committed a lot of mistakes, cause of lack of understanding, lack of knowledge, lack of English knowledge, but I still feel at home in here. When someone recognizes my efforts, I feel great; when my ears are pulled, I feel sorry. But I have never felt mistreated. Hope everyone writing to this forum feel the same. I extend my interest on reading the Ex-PPC Member posts, too, cause they have always called our attention to something of common interest, as this huge challenge of the Trigs in the 12C. I spent last night awaken and felt intrigued not finding a reasonable, efficient solution for sine only! Please, keep teasing us! No hard feelings, please. The Forum is a gift from Mr. Hicks. Thanks.

 Re: HP-12C Trigs [Final] - An opinionMessage #4 Posted by John Mills on 18 Oct 2001, 11:54 a.m.,in response to message #2 by Andrés C. Rodríguez (Argentina) i don't agree with Mr. Rodrigues observation that the style of exppc member isn't proper for this forum. He hasn't insulted anyone, has explicitly thanked everyone who contributed and after reading all the messages he posted about this subject it's clear to me that he's always stated in unambiguous terms what he exactly wanted but after much talk, sometimes completely irrelevant, no one ever produced a single line of 12c code so you can't blame him for saying exactly that. just my two cents.

 Re: HP-12C Trigs [Final] - An opinionMessage #5 Posted by Andrés C. Rodríguez (Argentina) on 18 Oct 2001, 12:35 p.m.,in response to message #4 by John Mills I don't mean Ex-PPC insulted someone, in fact he thanked all who contributed, what is very proper. But I felt some tone of discomfort, disappointment or irritation in his message. Of course, I am not parting with anyone (or against anyone) who participated on the thread, nor favoring any answer to the programming challenge. I (and I suppose many other people here) read and benefit from most threads, even those where I have no particular interest or knowledge to bring. That is why I think none should criticize others for submitting "non-optimal" answers. Please keep this place open and candid, and also give some allowance for us who don't have English as our primary language, if sometimes our wording is "non-optimal".

 Re: HP-12C Trigs [Final]Message #6 Posted by Viktor Toth on 18 Oct 2001, 9:27 a.m.,in response to message #1 by Ex-PPC member Hmmm. If you can implement a sine routine in only 18 steps, surely you don't find it difficult to add a few (<10?) extra steps to compute the cosine and the tangent from a known sine value. The series expansion for, say, arc sine isn't much more difficult either, and again, a few extra steps can't be a problem. And then, you'll have a nice program in memory that, with several different entry points, would compute any one of the six trig functions. Which leads me to believe that I am missing a point here; are you after a program that computes all six values AT THE SAME TIME perhaps? Like, depositing all six into registers 1-6 or something like that? Or is it something else altogether? Viktor

 Re: HP-12C Trigs [Final]Message #7 Posted by Vieira, Luiz C. (Brazil) on 18 Oct 2001, 10:29 a.m.,in response to message #6 by Viktor Toth Hello; I thought the same cause it is sometwhat easier, as the tiny 12C does not support subroutines. A one launch program that computes sine (Taylor series?) and stores, obtains cosine (Pitagoras) and divide both for tangent would not use so much program lines. I did not stop to think about the inverses... Any clue?

 Re: HP-12C Trigs [Final]Message #8 Posted by Viktor Toth on 18 Oct 2001, 10:59 a.m.,in response to message #7 by Vieira, Luiz C. (Brazil) I actually have a program that computes the sine, cosine and tangent simultaneously using the Taylor series. I have another program that computes _either_ the arc sine, the arc cosine, or the arc tangent (i.e., the program has three different entry points). The two together fit into 70-some steps. I was wondering if this is the kind of program our friend here was looking for, if it I am completely off track here. Viktor

 Re: HP-12C Trigs [Final]Message #9 Posted by Vieira. Luiz C. (Brazil) on 18 Oct 2001, 4:13 p.m.,in response to message #8 by Viktor Toth I'm interested on this, too. Would you be as kind as for posting the programs listing in here? Just steps like: 00 ENTER STO 0 RCL 1 1/X y^x 05 x<>y ... Maybe you have the final frontier for these posts... and a blank flag! Thanks

 Re: HP-12C Trigs [Final]Message #10 Posted by Viktor Toth on 19 Oct 2001, 10:13 a.m.,in response to message #9 by Vieira. Luiz C. (Brazil) Here it is. The first program at address 01 computes the cosine, tangent, and sine of the argument (in radians) and places the result in this order in X, Y, and Z. If all you need is the sign, you can stop at step 24. The second program has three entry points (marked) for computing the arc cosine, arc tangent, and arc sine of the argument. The result is in radians. Both programs are reasonably accurate (and fast) for small arguments (-PI < x < PI for the trigonometric functions, -1 < x < 1 for the inverses.) You can test the programs by entering a small argument, running the first program with [R/S] (this places the cosine in X) and then hitting [R/S] again to compute the arc cosine. If everything is correct, you should get back your original argument, plus or minus a small rounding error. ```01 STO 0 02 STO 1 03 1/x 04 STO 2 05 STO+2 06 RCL 2 07 STO/1 08 Rv 09 STO+2 10 RCL 2 11 CHS 12 STO/1 13 RCL 0 14 RCL 1 15 STO+0 16 CLX 17 RCL 0 18 - 19 x=0 20 GTO 24 21 Rv 22 Rv 23 GTO 05 24 LASTx X=sin 25 1 26 LASTx 27 ENTER 28 X 29 - 30 SQRT 31 / 32 LASTx 33 R/S X=cos Y=tan Z=sin ============= 34 acos ENTER 35 X 36 1 37 - 38 CHS 39 SQRT 40 GTO 48 41 atan ENTER 42 ENTER 43 X 44 1 45 + 46 SQRT 47 / 48 asin STO 0 49 STO 1 50 ENTER 51 X 52 1 53 STO*1 54 STO*1 55 1 56 + 57 STO/1 58 1 59 + 60 STO/1 61 x-y 62 STO*1 63 x-y 64 RCL 0 65 RCL 1 66 STO+0 67 CLX 68 RCL 0 69 - 70 x=0 71 GTO 74 72 Rv 73 GTO 53 74 LASTx 75 GTO 00 ``` Viktor

 Re: HP-12C Trigs - Complete at Viktor´s previous postMessage #11 Posted by Vieira, Luiz C. (Brazil) on 19 Oct 2001, 10:39 a.m.,in response to message #10 by Viktor Toth Thanks, Victor! Good programming! Eficient code! As I always say to my studentes: the best solution is the one that points to the answer and, when possible, gives the answer. Thanks again.

 Re: HP-12C Trigs [Final]Message #12 Posted by W. Bruce Maguire II on 19 Oct 2001, 12:09 p.m.,in response to message #10 by Viktor Toth Viktor: Thanks for the submission! I'm anxious to put the program into my 12c---and when I get a chance---to look at the code. It is always fun to try to customize an already-nice piece of software! I haven't even looked at the code yet, but one thing I noticed is that it is only 75 steps! Wow! Thanks again, Bruce.

 Congratulations to Viktor!Message #13 Posted by Andrés C. Rodríguez (Argentina) on 19 Oct 2001, 12:23 p.m.,in response to message #10 by Viktor Toth Viktor: While I am not particularly interested in this challenge (lack of time to program, lack of a 12C, lack of a real need, and lack of good algorithms after 20 years from graduation...) I'd like to say THANK YOU for a elegant solution, insightful description, and constructive posting. Looking at your listing, I had a deja-vu feeling from the HP-25 programming style, where interesting things could be done in few steps and without flags, subroutines, looping constructs... Andrés (Frequent-MoHPC Visitor)

 Re: HP-12C Trigs - will you submit your prgm?Message #14 Posted by Vieira, Luiz C. (Brazil) on 20 Oct 2001, 10:36 p.m.,in response to message #10 by Viktor Toth Hello; I believe I speak for the others when asking you, please, to submit your HP12C Trigs for the HP Museum Software Library. It fairly deserves a place in there. I myself did not realize (till now) that your program is one to be there. As the Ex-PPC Member believed this was to be very well known, it's time to make it very well known. With your consent, of course. If others agree, take it as an invitation. Thanks.

 Re: HP-12C Trigs - will you submit your prgm?Message #15 Posted by Viktor Toth on 21 Oct 2001, 9:54 p.m.,in response to message #14 by Vieira, Luiz C. (Brazil) Program submitted to the Articles forum. Thanks for the encouragement! Viktor

 Re: HP-12C Trigs [Final] - Another opinionMessage #16 Posted by W. Bruce Maguire II on 18 Oct 2001, 12:21 p.m.,in response to message #1 by Ex-PPC member Andrés C. Rodríguez (Argentina) wrote: -------------------- Dear Ex-PPC member: I am just a frequent visitor or participant here, certainly not a moderator nor more than another peer. I would like to say to you (it would be nice to state your name, but it is your choice to be nice or not) that I personally think the style of your message is not the proper one here. : : -------------------- I would like to say that I share this opinion. Mr "Ex-PPC Member," I would implore you---for the second time---to post what you have already written. You said that you did not think that the formatting would allow such a posting. I pointed you to my last program posting: Improved TRIG. and INVERSE TRIG. functions for the HP-17BII, W. B. Maguire II - 26 Sept 2001, 12:42 p.m. and explained where to find the information on the very-simple formatting. All you need to do, is preface the program listing with "[pre:" and end it with a "]", and everything in between will be shown with a uniformly-spaced font, and all spaces and new-lines will be honored. Please see http://www.hpmuseum.org/artfmt.htm. Yes, it will require a bit of effort to submit your program listing, but that is what this group is about, give and take. You seem only interested in taking. I also suggested that if you post what you have, others might be able to "take it and run with it," and provide a solution for us all. You seem to want someone to give you a complete solution, but you are unwilling to present your work. I'm sure we're all very sorry that you are disappointed with the community! You even go to the point of deriding a routine for the 12c that you have never even seen---a routine submitted by one of the most famous, knowledgeable, and prolific HP enthusiasts! I have offered you my suggestions. I've submitted my own routines for the 17BII (even though I was quite sure that someone could improve them). So far, you have contributed nothing but attitude. Bruce. p.s. Have you ever noticed how everyone else offers their name on their posts---and isn't afraid to provide their E-mail?

Go back to the main exhibit hall