Hi, who needs urgently fatan - this is an aproximation, 5+ digits
precision for small arguments (-1..+1).

\ fatan library
\ amforth 4.0
\ Pito 26-9-2010
\ v 1.0.
\ needs Leon's flib (and Pito's asm flib v1.1 for speed)
-fatan
marker -fatan
\ calculate fatan
: fatan ( RAD -- arctangens )
\ x
fdup fdup f*    \ x^2
fover fover f*  \ x^3
fover fdup f*   \ x x^2 x^3 x^4 --      
$E04D $3D6E f*  \ 0.05831938*x^4
frot   $B24E $3F43 f*       \ 0.76443945*x^2
$0000 $3f80 f+ f+            \ 1 + 0.76443945*x^2 + 0.05831938*x^4
frot frot $F805 $3EDC f* f+   \ (x + 0.43157974*x^3)
fswap f/ ;

******************************
Ex:
> _half fatan fs.
4.636495E-1  ok
> _third fatan fs.
3.2175684E-1  ok
> _-1 _1e-2 f* fatan fs.
-9.999667E-3  ok
> _1 _1e-3 f* fatan fs.
9.999997E-4  ok
> _1 _1e-3 f- fatan fs.
7.848919E-1  ok
> _-1 _half fatan fs.
4.636495E-1  ok
> _-1 _half f* fatan fs.
-4.636495E-1  ok
> _-1 _third f* fatan fs.
-3.2175684E-1  ok
> _third fatan fs.
3.2175684E-1  ok



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Amforth-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/amforth-devel

Reply via email to