Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: High level ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 4017 of 4065
Post > Topic >>

Re: High level FSIN and FCOS

by Aleksej Saushev <asau@[EMAIL PROTECTED] > Apr 26, 2008 at 11:53 AM

"The Beez'" <hansoft@[EMAIL PROTECTED]
> writes:

> Hi!
>
> Does anyone have some high level source for FSIN and FCOS words?

: fsinn ( x -- {sin x}/x )
  fsqr  1 >f  fswap  1 >f  0 >r  begin ( a x^2 t ; k )
  1 r+!  fover f*  r 2* >f f/  r 2* 1+ >f f/ fnegate ( a x^2 t' ; k' )
  frot  fover fover f+ ( x^2 t' a a' ; k' )
  ftuck f= >r f-rot r> until ( a' x^2 t' ; k' )
  fdrop fdrop  r> drop
;
: fsin  fdup fsinn f* ;

: r+!  rp@[EMAIL PROTECTED]
 +! ;
: >f  s>d d>f ;
: f-rot  frot frot ;

Obviously, it won't work for large arguments, you need another
way to calculate Taylor serie, but you want to take argument modulo pi
anyway.

cos(x) = sin (pi - x)

> BTW, FLN, F** or others are appreciated as well.

x^y = exp(y ln x)

Logarithm is problematic.
Taylor series for ln (1+x) converge for |x| < 1.
The best approach is probably extracting decimal order,
thus reducing to arguments between 1 and 10.


-- 
BECHA...
   CKOPO CE3OH...




 8 Posts in Topic:
High level FSIN and FCOS
"The Beez'" <  2008-04-25 10:48:48 
Re: High level FSIN and FCOS
Aleksej Saushev <asau@  2008-04-26 11:53:58 
Re: High level FSIN and FCOS
Albert van der Horst <  2008-04-26 08:02:23 
Re: High level FSIN and FCOS
Bill <foo@[EMAIL PROTE  2008-04-26 09:56:23 
Re: High level FSIN and FCOS
"Ed" <nospam  2008-04-27 12:52:17 
Re: High level FSIN and FCOS
Albert van der Horst <  2008-04-27 11:17:52 
Re: High level FSIN and FCOS
"Rod Pemberton"  2008-04-26 21:56:38 
Re: High level FSIN and FCOS
"Mark W. Humphries&q  2008-04-26 20:00:09 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 5:10:55 CDT 2008.