Re: High level FSIN and FCOS



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