▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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 y^{x} nor n! is used there. I decided to go further and the results are in this article:
HP16C 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
▼
Posts: 1,107
Threads: 159
Joined: Jan 1970
Small suggestion?
How about trying to get it rewritten 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?
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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
▼
Posts: 209
Threads: 12
Joined: Jan 1970
Am I stupid in thinking that *(yes, quite likely I am)* the inverse is simply 1/function, as in "1/sin is arcsine", etc.?
▼
Posts: 1,107
Threads: 159
Joined: Jan 1970
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
▼
Posts: 209
Threads: 12
Joined: Jan 1970
I needed to go to your High School.
Well, actually, attending mine would have helped, too.
;)
Posts: 4,027
Threads: 172
Joined: Aug 2005
Hi;
after Taylor's polynomial development, we have:
sin(X) = (X^{1})/1!  (X^{3})/3! + (X^{5})/5!  (X^{7})/7! + ....
and: cos(X) = (X^{2})/2! + (X^{4})/4!  (X^{6})/6! + (X^{8})/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 viceversa.
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
▼
Posts: 1,755
Threads: 112
Joined: Jan 2005
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.
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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
Posts: 406
Threads: 47
Joined: Jul 2005
I love Luis' US$ 0.02 worth. What happened to the old cent sign (a "c" with a slash through it)?
tm
▼
Posts: 61
Threads: 17
Joined: Jan 1970
I had thought that the old cent sign went away when keyboards started needing a "1" (number one) and couldn't substitute an "l" (lowercase 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.
▼
Posts: 1
Threads: 0
Joined: Jan 1970
Posts: 172
Threads: 5
Joined: Jan 1970
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
Posts: 406
Threads: 47
Joined: Jul 2005
Liuz,
I must apologize for mispelling your name.
tm
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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?)
Posts: 776
Threads: 25
Joined: Jun 2007
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_n1)) < tolerance
to decide if it was OK to quit adding terms.
▼
Posts: 266
Threads: 32
Joined: Jan 1970
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 exmathematician, so don't ask me to translate that into English... ;)
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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_n1)) < tolerance
more as a concern for number of computed terms and consequently time to compute than for leastsignificant 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}), nonasymptotic (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
▼
Posts: 406
Threads: 47
Joined: Jul 2005
Luiz,
Now you've done it! How did you print the cent sign?!!
tm
Posts: 4,027
Threads: 172
Joined: Aug 2005
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
▼
Posts: 406
Threads: 47
Joined: Jul 2005
Luiz,
The cent sign discussion has been fun. I'm so pleased that through this forum I have been able to have my HP67 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
▼
Posts: 4,027
Threads: 172
Joined: Aug 2005
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
Posts: 909
Threads: 40
Joined: Jan 1970
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?
