Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/4th/lib/zenfasin.4th

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


\ 4tH library - FASIN FACOS FATAN ZEN - Copyright 2009 J.L. Bezemer
\ You can redistribute this file and/or modify it under
\ the terms of the GNU General Public License

[UNDEFINED] fasin [IF]
[UNDEFINED] +taylor [IF] include lib/zentaylr.4th [THEN]
[UNDEFINED] fsqrt   [IF] include lib/zenfsqrt.4th [THEN]

: 2degrees 1+ 1+ dup >r -taylor r> 1+ 1+ dup >r +taylor r> ;
: (taylor) 1 2degrees 2degrees 2degrees 2degrees 2degrees drop 2drop 2drop ;
: >range 1 s>f 2over 2dup f* 2over f+ fsqrt f+ f/ ;
: (fatan) 2dup >taylor (taylor) ;
: range? f< if >range (fatan) 2dup f+ else (fatan) then ;
: fatan 75 -2 2over fabs range? ;
: (fasin) 1 s>f 2over 2dup f* 2over 2swap f- fsqrt f+ f/ fatan 2dup f+ ;
: fasin 2dup fabs 1 s>f f= if 314159265 -8 2 s>f f/ f* else (fasin) then ;
: facos fasin 314159265 -8 2 s>f f/ 2swap f- ;

[DEFINED] 4TH# [IF]
hide 2degrees
hide (taylor)
hide (fatan)
hide (fasin)
hide >range
hide range?
[THEN]
[THEN]


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].