anchor.diff:      3 of dnegate pi/2 d+ cosine         endof
     endcase
   
  -  2-foldable ;
  +2-foldable ;
   
   : widesine ( f-angle -- f-sine )
     dup >r \ Save sign
  
positive.code:   endcase
  
    r> 0< if dnegate then
    2-foldable ;
  
negative.code: \ Trigonometric functions with CORDIC algorithm
  \ copied with minor mods from Mecrisp Stellaris "common/sine.txt"
  
  \ -----------------------------------------------------------------------------
  \   Constant table necessary for all CORDIC computations
  \ -----------------------------------------------------------------------------
  
  create cordic-const
  hex
    C90FDAA2 , 76B19C15 , 3EB6EBF2 , 1FD5BA9A ,
    0FFAADDB , 07FF556E , 03FFEAAB , 01FFFD55 ,
  
    00FFFFAA , 007FFFF5 , 003FFFFE , 001FFFFF ,
    000FFFFF , 0007FFFF , 0003FFFF , 0001FFFF ,
  
    0000FFFF , 00007FFF , 00003FFF , 00001FFF ,
    00000FFF , 000007FF , 000003FF , 000001FF ,
  
    000000FF , 0000007F , 0000003F , 0000001F ,
    0000000F , 00000007 , 00000003 , 00000001 ,
  decimal
  
  cordic-const constant cordic-constants \ Allow stronger optimisations for the table address
  
  : e^ka ( u -- x ) 2 lshift cordic-constants + @  1-foldable ;
  
  \ -----------------------------------------------------------------------------
  \   Common building blocks for different CORDIC modes
  \ -----------------------------------------------------------------------------
  
  0. 2variable cordic-x
  0. 2variable cordic-y
  0. 2variable cordic-z
  
  0. 2variable cordic-x'
  
  : 2arshift ( d u -- d* ) 0 ?do d2/ loop 3-foldable ;
  
  : cordic-step-plus ( -- )
    cordic-x 2@ cordic-y 2@ i 2arshift d+ cordic-x' 2!
    cordic-y 2@ cordic-x 2@ i 2arshift d- cordic-y  2!
    cordic-z 2@             i e^ka 0   d+ cordic-z  2!
  
    cordic-x' 2@ cordic-x 2!
  ;
  
  : cordic-step-minus ( -- )
    cordic-x 2@ cordic-y 2@ i 2arshift d- cordic-x' 2!
    cordic-y 2@ cordic-x 2@ i 2arshift d+ cordic-y  2!
    cordic-z 2@             i e^ka 0   d- cordic-z  2!
  
    cordic-x' 2@ cordic-x 2!
  ;
  
  \ -----------------------------------------------------------------------------
  \   Angle --> Sine and Cosine
  \ -----------------------------------------------------------------------------
  
  : cordic-sincos ( f-angle -- f-cosine f-sine )
                  ( Angle between -Pi/2 and +Pi/2 ! )
  
    $0,9B74EDA8  cordic-x 2! \ Scaling value to cancel gain of the algorithm
     0,0         cordic-y 2!
                 cordic-z 2!
  
    32 0 do
      cordic-z 2@ d0<
      if
        cordic-step-plus
      else
        cordic-step-minus
      then
    loop
  
    cordic-x 2@
    cordic-y 2@
  
  2-foldable ;
  
  : cosine ( f-angle -- f-cosine ) cordic-sincos 2drop  2-foldable ;
  : sine   ( f-angle -- f-sine )   cordic-sincos 2nip   2-foldable ;
  
  \ -----------------------------------------------------------------------------
  \   Range extension for Sine and Cosine
  \ -----------------------------------------------------------------------------
  
  3,141592653589793  2constant pi
  pi 2,0 f/          2constant pi/2
  
  : widecosine ( f-angle -- f-cosine )
    dabs
  