HP Forums
Trigonometrics with the HP16c (no inverses so far) - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: Trigonometrics with the HP16c (no inverses so far) (/thread-33876.html)



Trigonometrics with the HP16c (no inverses so far) - Vieira, Luiz C. (Brazil) - 05-13-2003

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


Re: Trigonometrics with the HP16c (no inverses so far) - Gene - 05-13-2003

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?


One small remark... - Vieira, Luiz C. (Brazil) - 05-13-2003

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


Re: One small remark... - Glynn - 05-13-2003

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


Nope, not the same - Gene - 05-13-2003

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


Re: Nope, not the same - Glynn - 05-13-2003

I needed to go to your High School.

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

;-)


Re: One small math remark... - Vieira, Luiz C. (Brazil) - 05-13-2003

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


Re: One small math remark... - Valentin Albillo - 05-13-2003

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.




YES! - Vieira, Luiz C. (Brazil) - 05-13-2003

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




Re: One small math remark... - Trent Moseley - 05-13-2003

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

tm


Re: One small math remark... - Dan M - 05-13-2003

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.


Re: One small math remark... - Dan Thanks - 05-13-2003

Dan,

Thanks!

tm


Re: One small math remark... - Dave Shaffer (Arizona) - 05-13-2003

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.


Cent and other non-ASCII characters - Michael F. Coyle - 05-13-2003

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

&cent;
&#162;

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&cent;.

- Michael


Re: One small math remark... - Patrick - 05-13-2003

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... ;-)


Re: One small math remark... - Vieira, Luiz C. (Brazil) - 05-14-2003

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


Luiz I Apologize - Trent Moseley - 05-14-2003

Liuz,

I must apologize for mispelling your name.

tm


Re: One small math remark... - Trent Moseley - 05-14-2003

Luiz,

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

tm


Re: Luiz I Apologize - Vieira, Luiz C. (Brazil) - 05-14-2003

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?)


Secret ¢ symbol... not anymore. - Vieira, Luiz C. (Brazil) - 05-14-2003

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


Re: Secret ¢ symbol... not anymore. - Trent Moseley - 05-14-2003

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


I have my own happy stories... - Vieira, Luiz C. (Brazil) - 05-14-2003

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


Re: Secret ¢ symbol... not anymore. - Ellis Easley - 05-14-2003

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?