Re: High level FSIN and FCOS
- From: Aleksej Saushev <asau@xxxxxxxx>
- Date: Sat, 26 Apr 2008 11:53:58 +0400
"The Beez'" <hansoft@xxxxxxxxxxx> 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@ +! ;
: >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...
.
- References:
- High level FSIN and FCOS
- From: The Beez'
- High level FSIN and FCOS
- Prev by Date: Re: advantages of forth over other languages
- Next by Date: Re: High level FSIN and FCOS
- Previous by thread: High level FSIN and FCOS
- Next by thread: Re: High level FSIN and FCOS
- Index(es):