New Trigonometric Functions Program for the HP-12C



#5

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.


#6

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!


#7

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.


#8

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


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 805 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  HP Prime - CAS functions in Spreadsheet App CR Haeger 6 886 11-11-2013, 12:37 AM
Last Post: Michael de Estrada
  [41CL] New Extra Functions version Monte Dalrymple 0 381 11-08-2013, 04:32 PM
Last Post: Monte Dalrymple
  HP Prime: in need of help with defining functions Alberto Candel 14 1,479 10-27-2013, 10:48 AM
Last Post: Alberto Candel
  HP Prime spreadsheet functions SanS 0 820 10-04-2013, 04:23 AM
Last Post: SanS
  Stats functions on the HP34S Nicholas van Stigt 5 694 09-24-2013, 02:45 AM
Last Post: Nick_S
  Trig Functions Howard Owen 11 1,154 09-16-2013, 02:53 PM
Last Post: Fred Lusk
  50g piecewise functions Kurt Fankhauser 6 720 09-15-2013, 08:01 PM
Last Post: Kurt Fankhauser
  Computer-scientist functions on HP Prime? Michael O. Tjebben 12 1,181 08-22-2013, 06:59 PM
Last Post: plivesey
  Missing functions on the HP Prime!!!??? :-( Namir 6 722 08-22-2013, 08:40 AM
Last Post: Gilles Carpentier

Forum Jump: