Hi,
I have submitted an article to the Articles Forum (Hyperbolic Approximations for Trigonometric Functions on the HP-12C). The 99-step program uses only the stack, leaving the financial registers and all the seven remaining registers free for the user. The average percent error is 0.05% never being greater than 0.10% all through the valid ranges, which is enough for practical purposes. Running times are about 4 to 5.5 seconds, depending on the function only, not on the arguments. All inputs and outputs are in degrees.
For more details, those of you still interested please take a look at:
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=470
Regards,
Gerson W. Barbosa
Edited: 27 Feb 2005, 8:16 a.m.
woot! the code makes good reading. i like the atan and the evalualtion cascade particularly without memories. pity about the ln(x).
i think there are a couple of silly mistakes tho’ in your article. some of the expressions are missing a bracket and the arcos expression is missing the arctan. and should the 90- be a 90+ ?
good stuff. i just had to key it in!
Thank you for having pointed me out the mistakes. I have corrected the expressions and double-checked them.
Hugh Steers wrote:
Quote:
pity about the ln(x).
I didn't like the ln(x) either, but this is the only way I found to recover x from the stack at that point. LN is a time consuming function I wanted to avoid. This causes the result to come out 500 to 600 ms later than it could, and this is a lot of time. That is, this instruction alone is responsible for about 10% of the total running time.
Hugh Steer wrote:
Quote:
i think there are a couple of silly mistakes tho’ in your article. some of the expressions are missing a bracket and the arcos expression is missing the arctan. and should the 90- be a 90+ ?
Actually there were more than a couple of silly mistakes (Having finished writing the article at 3:00 am last Friday might be an excuse).
You are right: the 90- should be a 90+. Thanks again.
All expressions may be copied and pasted to an equation plotter to graphically check the accuracy. Examples:
a)
Eq. 1: y=cos(pi*x/180)
Eq. 2: y=(4-(exp(x/68.3393)+1/(exp(x/68.3393))))/(2exp(x^2/21813))
x range: -550, 550
y range: -2, 2
b)
Eq. 1: y=(180/pi)atan(x);
Eq. 2: y=1844.6((exp(x)-1/exp(x))/(exp(x)+1/exp(x)))/(32.2-(abs(x))^3)
Eq. 3: y=90+1844.6((exp(-1/x)-1/exp(-1/x))/(exp(-1/x)+1/exp(-1/x)))/(32.2-(abs(-1/x))^3)
x range: -1, 10
y range: -10, 100
Regards,
Gerson
Edited: 27 Feb 2005, 5:01 p.m.
great.
what i liked about your approach is that i'd never thought of approximating trigs with hyperbolics before. this is a good idea when you need to reduce the number of constants in the program (as these take up too many steps).