# Variable calculations should be done in this file.
# It is read and interpreted by wims for all valid calls to the module.

nit=<i><font color=blue>n</font></i>
default num_style=1
!!num_style=1
!default precision=20
!if $precision > 2000
 precision=2000
!endif
pari_precision=$[2*$precision]
sign0=-
sign1=+
sign2=+

numerator=!item $num_style of 1,-1,(-1)^n,-(-1)^n

!if $cmd=reply
 formula=!lowercase $formula
 formula=!rawmath $formula
 !if $module_language=fr
  formula=!replace , by . in $formula
 !endif
 wims_module_log=dev $formula
 !if $num_style != 1
 ddd=!exec pari \v\
   formula=$formula;print(formula)\
   print(contfrac(formula,vector($precision+2,n,$numerator)))
 !else
 ddd=!exec pari \v\
   formula=$formula;print(formula)\
   print(contfrac(formula))
 !endif
 gp_version=!line 1 of $ddd
 gp_version=!word 4 of $gp_version
 n=!line 2 of $ddd
 devel=!line 3 of $ddd
 !if $n = $empty
   error_test1=?
   !exit
 !endif
 devel=!trim $devel
 fn=!itemnum $devel
 myn=!eval $n
 error_test1=!word 1 of $n
 int_part=!item 1 of $devel
 !if $num_style=2 or $num_style=3
   int_part=!eval -$int_part
 !endif
!endif

