Trigonometrics with the HP16c (no inverses so far)



#5

Hi, folks (mostly HP16C fans);

After all of these HP12C's related messages, posts and the like, I took the excellent Viktor Toth's Trig program listing and took a large look at it. I must tell that there are other excellent programs, like Valentin's "Tricky Trigonometric" for the HP12C. At the time I first saw Viktor's version, I wondered what sort of algorithm did he use, since neither yx nor n! is used there. I decided to go further and the results are in this article:

HP-16C Trigonometric Functions (no inverses so far)

If any of you could have a look at it, also try it in your HP16C, I'd gladly accept any suggestions, comments, adds, etc. Mostly if there is anything wrongly written (I like learning).

Thank you.

Luiz C. Vieira - Brazil


#6

Small suggestion?

How about trying to get it re-written where you can do a GSB 1 to get SIN, GSB 2 to get COS, and GSB 3 to get TAN?

I know that it generates all three, but if they acted more like separate routines, it might be nice to call them with a GSB X from the keyboard.

How much headache would this cause?


#7

Hello, Gene;

thank you for the suggestion; it will be no headache to accomplish.

What bothers me is the fact that at least sine or cosine must be first computed, and it means the complete series must be evaluated till error = 0 for at least one of them: SIN or COS. It would only take a lot of time, almost the same amount for each of them, because computing cosine or tangent given sine is neglectible in this case.

Despite of the time spent, the rest is somewhat easy. I'll post it later at this very thread.

I'm still trying to find the time to "delve into" inverses...

Thank you for the feedback.

Luiz C. Vieira - Brazil


#8

Am I stupid in thinking that *(yes, quite likely I am)* the inverse is simply 1/function, as in "1/sin is arcsine", etc.?


#9

Sine is the ratio of the opposite over the hypotenuse ( which of course also defines the angle).

Inverse takes the ratio and gives you the angle it came from.

Example triangle, adjancent = 3 units long, opposite = 4 units long, hypotenuse = 5 units long.

Sine = 4/5 or 0.8
Arcsine of 0.8 = 53.13 degree angle.

I have never forgotten this since HS. Chief SOH CAH TOA!

Sine = Opposite / Hypotenuse
Cosine = Adjacent / Hypotenuse
Tangent = Opposite / Adjacent


#10

I needed to go to your High School.

Well, actually, attending mine would have helped, too.

;-)

#11

Hi;

after Taylor's polynomial development, we have:

sin(X) = (X1)/1! - (X3)/3! + (X5)/5! - (X7)/7! + ....

and:
cos(X) = -(X2)/2! + (X4)/4! - (X6)/6! + (X8)/8! + ....
Each new term is a lot smaller than the previous one, and in the calculator's predefined accuracy, when a new term no longer changes the final result, the other ones will not change too, so it's time to stop. The relation between sine and cosine is known as:
(sin(X))2 + (cos(X))2 = 1 (Pythagorean)
Also, the tangent relation is:
sin(X)/cos(X) = tan(X)

The key is finding either sin(X) or cos(X) and apply final two identities to compute tan(X) and the remaining cos(X) if sin(X) is found or vice-versa.

Please, if I miss(pelled) something or committed a math crime in here, I plied guilty and ask for mercy... I beg to the jury to consider that I wrote it by heart, do not have my notes or books in hands.

Otherwise, is that easy to get?

My US$ 0.02 contribution.

Luiz C. Vieira - Brazil


#12

Just one small correction:

Luiz wrote:

"cos(X) = -(X^2)/2! + (X^4)/4! - (X^6)/6! + (X^8)/8! + ...."

Actually, it should be:

"cos(X) = 1 -(X^2)/2! + (X^4)/4! - (X^6)/6! + (X^8)/8! + ..."

with the extra "1" at the beginning. Best regards.


#13

Hi, Valentin;

It's the

(X)0/0! 
term that I forgot (I always do that since high school..)

Thank you very much!

Luiz C. Vieira - Brazil

#14

I love Luis' US$ 0.02 worth. What happened to the old cent sign (a "c" with a slash through it)?

tm


#15

I had thought that the old cent sign went away when keyboards started needing a "1" (number one) and couldn't substitute an "l" (lower-case L). But upon looking, it's not even in ASCII anywhere. Google pointed towards a better believable explanation than I could come up with.

http://www.charlieanderson.com/centsign.htm

gone also from keyboards and ASCII are 1/4, 1/2, 3/4.

I miss the old cent sign, and deplore its misuse in modern times on store signs and such: 0.25c which really means 25c.

Oh well, such is progress and standardization.


#16

Dan,

Thanks!

tm

#17

HTML has special encodings for lots of odd but useful symbols. There are two formats:

¢
¢

No matter how hard I try, though, the symbol doesn't come out in the message here; either Dave's software or my Web Browser does something to prevent it.

Unicode also defines the cent as character 162.

My 2¢.

- Michael

#18

Liuz,

I must apologize for mispelling your name.

tm


#19

Hi, Trent;

I did not even notice that; don't worry, it's somewhat hard from people that come from different cultures to keep track with correct spelling, mostly when proper names are the issue.

You see, you wrote Liuz instead of Luiz in your apologetic post... Don't bother yourself; there is no special "hard" meanning with these changes.

Thanks for your care.

Luiz C. Vieira - Brazil

(have you found the

¢
symbol?)
#20

Luiz,

I think you are right about the Taylor series expansion - you can quit when the next term is too small.

But: something like this is what got HP into trouble on the original HP35 algorithms. Remember the famous ln(exp(2.02)) (or reverse?) which gave "2" for the answer? At some point, in whatever expansion HP used to evaluate the offending function, the terms temporarily looked like they had converged, but there were larger terms farther out in the expansion. I think the programmers did some comparison on the order of

if(abs(iteration_n - iteration_n-1)) < tolerance

to decide if it was OK to quit adding terms.


#21

In a convergent alternating series (i.e., each term has a different sign), the total error you make in truncating the series is less than or equal to the first omitted term (in absolute value).

I'm an ex-mathematician, so don't ask me to translate that into English... ;-)


#22

Hi, guys;

I think the trick in here is that Viktor Toth used a program sequence where two terms are added each time the loop runs, what means two terms with opposite signs are added before tolerance (error) is tested. I think of it as a partial (perhaps complete) solution for testing convergent alternating series. Then, the worst case (and last one) is when both terms are added and there is no change in final accumulated value not because they have the same magnitude, but because their magnitude is below final value range.

I also take

if(abs(iteration_n - iteration_n-1)) < tolerance
more as a concern for number of computed terms and consequently time to compute than for least-significant digit accuracy. One question: in the HP35, with how many digits does the system deal internally?

If you take terms too closed to zero or to maximum/minimum you'll have division by zero and Error 0. But if they are not too close, like sin(1×10-4), non-asymptotic (faster) convergence occurs because terms are too far from each other. And there is the issue that internal algorithms will be dealing with more digits than any user program, right?

Man, I love discussions on these subjects! Makes me feel my brain cells are alive... after 41 years straight activity.

Wow!

By popular demand: my 2¢ contribution (my secret ¢ symbol...)

Luiz C. Vieira - Brazil


#23

Luiz,

Now you've done it! How did you print the cent sign?!!

tm

#24

Hi, Trent;

I'm running Windows and I opened Character Map and searched for ¢ in both Times New Roman and Courier New. It was there in both fonts. IN my keyboard configuration I get it with a shortcut:

[Shift]+[Ctrl]+[Alt]+[C]


It worked for me: ¢

And with preformated font, it looks even better:

 [pre] ¢ [/pre] 

Best regards.

Luiz C. Vieira - Brazil


#25

Luiz,

The cent sign discussion has been fun. I'm so pleased that through this forum I have been able to have my HP-67 card reader repaired after being out of service for so many years. Not that it is my prime calculator any more, but it's like an old friend that still works!

Best regards,

tm


#26

Hello, Trent;

I, as I believe many others, have my own happy "friendship" stories. In 1982 (or 1981?) I bought my first HP calcualtor: an HP41C with one memory module. It was kept spread around inside a shoes box for about eight years and I could rebuilt it after talking to a few guys in here. Good fellow that one. It is again in a box (not a shoes box, not spread around} because I had to use it's battery holder to power an HP41CX up. But it is still working alright.

I like knowing about these good, happy stories like yours.

Thanks.

Luiz C. Vieira - Brazil

#27

You can get (any?) character code in Windows by holding down ALT and then typing a 1 to 3 digit number on the numeric keypad. I don't know if all versions of Windows do this or do it the same, but I get the US cent sign with 155, the UK pound sign with 156, and the Japanese Yen with 157 (the last two must be on nationalized keyboards). Also I get "1/2" with 171 and what looks like "1/4" with 172. NUM LOCK has to be on. Without NUM LOCK, 155 gives the cent sign, but 156, 157 and 17 (alone) makes my browser load my home page!

¢ cent sign
£ pound
¥ Yen
½ one half
¼ one quarter?

Possibly Related Threads...
Thread Author Replies Views Last Post
  An easy course in using the HP16c-wanted- Frank 4 1,218 10-29-2013, 11:50 AM
Last Post: Mark Hardman
  HP16C (NOS !!) Mike Powell 22 3,017 09-30-2013, 02:18 AM
Last Post: Paul Dale
  How to find "inverses?" PhysicsNerd 10 1,587 11-28-2007, 03:02 PM
Last Post: Artur - Brazil
  Trigonometrics on the 17bii+ Les Wright 8 1,445 03-04-2007, 09:44 PM
Last Post: Les Wright
  Trigonometrics for Really Big Input Les Wright 18 2,590 02-24-2007, 10:38 PM
Last Post: Massimo Gnerucci (Italy)
  HP16C: Retrieving WSIZE (and a note about CCD ROM) Vieira, Luiz C. (Brazil) 0 425 08-07-2006, 10:26 AM
Last Post: Vieira, L. C. (Brazil)
  HP16C manual dated 9/83 John Leith 5 1,037 02-19-2006, 09:26 PM
Last Post: Vieira, L. C. (Brazil)
  Is this HP16C worth worth a new 49G+? Al Borowski 12 1,745 04-04-2004, 01:51 AM
Last Post: Al Borowski
  Trigonometrics in financial applications Valentin Albillo 17 2,348 06-30-2003, 10:36 AM
Last Post: Thibaut
  HP-12C trigonometrics Ex-PPC member 10 1,524 10-16-2001, 12:50 PM
Last Post: W. Bruce Maguire II

Forum Jump: