HP-12C trigonometrics



#12

Hi, I've recently got an HP-12C, and I'm trying to write
a program for it implementing all six trigonometric
functions that it lacks, namely sin, cos, tan, and their
inverses. Now, I'm pretty sure this must be old hat for
everyone, but I've never seen before such a program.
I would be grateful if someone could point me where to
find that program, so that I could compare with mine and
see how its author solved the many troubles I've suffered
while implementing it, namely extreme shortage of program
memory to implement all 6 functions at once at the
greatest possible accuracy (8 decimal places or better)
for all the range of input values.

My actual beta version implements everything except the
arc cosine function (no big deal, it can be easily
computed as pi/2-arc sine) with 8-10 decimal places
accuracy, and uses no numbered registers at all, but I
would love to see how other coped with this subject.


#13

Ex-PPC member (are you under-cover?):

Can you post the program? I would love to see it, as would others, I'm sure.

For the good of us all, maybe we'll start a sort of informal contest, where programs are presented for the 12C and 17BII to acomplish the trig. and inverse trig. functions. Seems reasonable to me---these two calculators are current, and both have advantages over the 32SII (the only current RPN scientific) excepting some key scientific functions. I would say that the 12C has a landscape-format advantage (for many people---I prefer the portrait format myself) and a number-display advantage, and the 17BII has numerous advantages over the 32SII (the 17BII is simply a much more powerful machine).

I recently submitted my solution for the 17BII, but I limited my solution to the region [0, PI/2]. I'm sure my program could be improved, but there doesn't seem to be an overwhelming interest...

Bruce.


#14

Thanks for your kind words. I don't know how to post the
program here, I guess a raw listing in a posted response
would get weirdly formatted, if at all.

The main difficulties I've found stem from the HP-12C's
extremely limited programming capabilities. You just have
to try and fit all 6 trig functions in 99 bytes ! That
wouldn't be so bad as it seems were it not for the fact
that you don't have labels, nor flags, only x<=y and
x=0 tests (which forces you to *substract* two values
and compare the result to zero, when you actually wanted
to compare one against the other), no indirect adressing, no increment/decrement instructions, and, most decisively,
you don't have subroutine capability (!!). That alone is
really the ultimate coup-de-grace to fit everything
accurately in so little memory. Matter of fact, I haven't
succeeded, I just can't find room enough to include
the arc cosine. Only the fact that it's easily computed
from the arc sine (pi/2-arcsin) saves the day. That's
why I'm so interested in looking at other people's
solutions to this particular programming issue. I'm sure
some must exist already.


#15

You can do it like:

[pre:
program line 1
program line 2
etc.
]
#16

If you can find a copy of the Collected Algorithms of the ACM (Association for Computing Machinery) from around 1976 +/- 3 years or so there is a "continued fraction" algorithm. As I rememeber it produces a couple of numbers that depending upon how you combine them gives you all the trig funcions, e^x, and hyperbolics. It has been a long time since I played with it but it was rather short, fast, and most interesting.


#17

Try:
M. Abramowitz and I. Stegun. Handbook of Mathematical Functions. Dover, 1972.

There you will find a lot of very useful approximations, easy to program for different levels of accuracy.

Jan


#18

I have once written a very short program for the HP38C that computed SIN, COS and TAN (no inverses), less than 15 steps. At that time I was studying for Electrical Eng. (long, long time ago...) and I have lost it. I remember computing Taylor series for sine and cosine (n! saved the day) and dividing both to compute tangent. It would fit perfectly in an HP12C.

I also remembered using TVM procedure to estimate energy consumption x production in a power plant. How many good stuff we had to do at that time...

Will anybody share the programs with us? I would if I had, I remember not even noting the steps, as the program was of no specific need of mine (only for that charming 19 Y.O. girl I cannot really forget the thankful face when my program ran smoothly on her HP38C).


#19

Luiz Claudio, if we put trigonometrics aside, it would be more interesting to know what happened later, with respect to that 19 Y.O. 8-) ?


#20

She got her Engineering graduation and... left many gratefull memories. I would like knowing where is she, right now. Just memories... Anyway, who does not have them?

|-(

(Hey, do you still need that material about the 41CX? Let me know...)

#21

All,

I have already posted the trig functions earlier here. See Forum Archive 6 entitled "Add trig functions on HP17BII, etc.? (You can)" for the source. I incorrectly stated that they were the Maclaughlin series--they're actually the Maclaurin series. They work quite well in both directions.

FYI and good luck,
M.


#22

Mike:

You seem to have missed the point. I, too, posted information on programming trig. functions into the HP-17BII, except my algorithms also include the INVERSE trig. functions, which is something that we are talking about here. I also included a full program listing. Look in the current forum page for:

Improved TRIG. and INVERSE TRIG. functions for the HP-17BII (Posted Sept. 26, 2001)

I actually had posted my first post on trig. functions for the 17BII on 7/31/2001 (horrible code---see the later post for details). I then followed it up on 9/26/2001 with a vastly superior implementation than the dumb one I first posted. Your article was posted on 9/3/2001. Please look at my 9/26/2001 post for an example of formatting that I think is acceptable for HP-17BII listings. As soon as you go into the Forum, there is a hyper-link to advanced formatting techniques.

The point here, is come up with code to fit these functions into a 12c. The 12c is a completely different programming beast than the 17BII, and is much more limited. That is what this thread is about.

If you are able to implement your algorithms on a 12c for all the trig. AND INVERSE TRIG. functions, please post a 12c listing!

Bruce.


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP 12C, 12C Platinum & 15C iOS App Walter Lam 2 862 06-02-2011, 01:25 PM
Last Post: Andrés C. Rodríguez (Argentina)
  Trigonometrics on the 17bii+ Les Wright 8 1,564 03-04-2007, 09:44 PM
Last Post: Les Wright
  Trigonometrics for Really Big Input Les Wright 18 2,830 02-24-2007, 10:38 PM
Last Post: Massimo Gnerucci (Italy)
  12C vs 12C Platinum Cash Flows Katie Wasserman 10 1,774 12-28-2005, 10:12 PM
Last Post: tony(nz)
  12c/12c Platinum programming differences Don Shepherd 6 1,318 08-11-2003, 10:11 AM
Last Post: Gene
  Trigonometrics in financial applications Valentin Albillo 17 2,544 06-30-2003, 10:36 AM
Last Post: Thibaut
  12C or 12C Platinum...that is the question Joe 3 859 06-21-2003, 11:39 PM
Last Post: Don Nguyen
  What's CPU of HP 12C and HP 12C Platinum Luc Chanh Truong 3 941 06-11-2003, 01:49 AM
Last Post: Vieira, Luiz C. (Brazil)
  Hi !! Gene, HP 12C vs 12C Platinum Luc Chanh Truong 0 528 06-09-2003, 10:28 PM
Last Post: Luc Chanh Truong
  Re: Inconsistent results #1: 12c vs. 12c Platinum hugh 1 617 05-14-2003, 03:22 PM
Last Post: Gene

Forum Jump: