FUNCTION :  qseries[jacprodmake] - Convert a q-series into a product of
                                   theta functions if possible
VERSION: May 4, 2010

CALLING SEQUENCE :  jacprodmake(f,q,T)
                    jacprodmake(f,q,T,P)
    
PARAMETERS :   f    - q-series
               T,P  - positive integers 

GLOBAL VARIABLES : xprint,ft0,fixjacp:
   
SYNOPSIS :   
   
 jacprodmake(f,q,T) converts the q-series f into a product of theta 
                                    T
 functions that agrees with f to O(q ).  

 Each theta-function has the form JAC(a,b), where a,b are integers
 and  0 < a < b.
        =     

 If 0 < a, then JAC(a,b) corresponds to the theta-product 

   a   b      b-a   b      b   b 
 (q , q )   (q   , q )   (q , q )
         oo           oo         oo 

If a = 0, then JAC(0,b) corresponds to the eta-product


   b   b                                    
 (q , q )                                   
         oo                                

 jacprodmake(f,q,T,P) is a version that searches for theta-products
 where b is a divisor of P. If xprint=true then extra information is
 printed as the program runs. An ERROR is returned if f is NOT a jac-prod.
 In this case the global var fixjacp saves the value of args.

 In this new version jacprodmake should still work even if the
 coefficient of q^0 is not 1.


EXAMPLES :   
   
> with(qseries);

> x:=tripleprod(q,q^5,10);

         99    70    46    27    13    4            7    18    34    55    81
   x := q   - q   + q   - q   + q   - q  + 1 - q + q  - q   + q   - q   + q

> jacprodmake(x,q,50);

                                    JAC(1, 5)

> XX:=series( (1- theta4(q,60)^2/theta4(q^5,12)^2)/4/q,q,60);

               3    4      5      6    7      8      9       10       11      12
XX := 1 - q - q  + q  + 4 q  - 4 q  - q  - 3 q  + 3 q  + 12 q   - 12 q   - 2 q

          13      14       15       16      17       18       19       20
     - 8 q   + 8 q   + 31 q   - 30 q   - 5 q   - 20 q   + 19 q   + 72 q

           21       22       23       24        25        26       27       28
     - 68 q   - 12 q   - 44 q   + 41 q   + 154 q   - 144 q   - 24 q   - 90 q

           29        30        31       32        33        34        35
     + 84 q   + 312 q   - 289 q   - 48 q   - 178 q   + 164 q   + 603 q

            36       37        38        39         40         41        42
     - 554 q   - 92 q   - 336 q   + 307 q   + 1122 q   - 1024 q   - 168 q

            43        44         45         46        47         48        49
     - 612 q   + 557 q   + 2024 q   - 1836 q   - 300 q   - 1087 q   + 983 q

             50         51        52         53         54         55         56
     + 3552 q   - 3206 q   - 522 q   - 1880 q   + 1692 q   + 6088 q   - 5472 q

            57         58      59
     - 886 q   - 3180 q   + O(q  )

> jacprodmake(XX,q,50);

                              JAC(1, 10) JAC(3, 10)
                              ---------------------
                                             2
                                   JAC(5, 10)

> V:=add(q^n/aqprod(q,q,2*n+1),n=0..100):
> jacprodmake(V,q,50); 
                    8   /                      2
JAC(0, 16, infinity)   /  (JAC(1, 16, infinity)  JAC(3, 16, infinity) JAC(4, 16, infinity)
                      /

                                                                  2
    JAC(5, 16, infinity) JAC(6, 16, infinity) JAC(7, 16, infinity) )

> xprint:=true:
> jacprodmake(V,q,50);
"jacmake started with args", _A, 49
                    8   /                      2
JAC(0, 16, infinity)   /  (JAC(1, 16, infinity)  JAC(3, 16, infinity) JAC(4, 16, infinity)
                      /

                                                                  2
    JAC(5, 16, infinity) JAC(6, 16, infinity) JAC(7, 16, infinity) )

> jacprodmake(V,q,50,16);
"_A done"
"jacmake started with args", _A, 49, 16
"TRYING period pp=", 2
"TRYING period pp=", 4
"TRYING period pp=", 8
"TRYING period pp=", 16
                    8   /                      2
JAC(0, 16, infinity)   /  (JAC(1, 16, infinity)  JAC(3, 16, infinity) JAC(4, 16, infinity)
                      /

                                                                  2
    JAC(5, 16, infinity) JAC(6, 16, infinity) JAC(7, 16, infinity) )

> jacprodmake(V,q,50,8);    
"_A done"
"jacmake started with args", _A, 49, 8
"TRYING period pp=", 2
"TRYING period pp=", 4
"TRYING period pp=", 8
                              ERROR: PP should be multiple of pp

Error, (in jacprodmake) jacprodmake failed (see gobal var fixjacp)

> Y:=add(q^(n*(n+1)/2),n=-20..20);
                  45      36      28      21      15      10      6      3      55      190
Y := 2 + 2 q + 2 q   + 2 q   + 2 q   + 2 q   + 2 q   + 2 q   + 2 q  + 2 q  + 2 q   + 2 q

          171      153      136      120      105      91      78      66    210
     + 2 q    + 2 q    + 2 q    + 2 q    + 2 q    + 2 q   + 2 q   + 2 q   + q

> jacprodmake(Y,q,100);           
                                    2 JAC(0, 2, infinity)
                                   ------------------------
                                   /JAC(1, 2, infinity)\1/2
                                   |-------------------|
                                   \JAC(0, 2, infinity)/


> V:=add( (q)^(n)/aqprod(q,q,max(min(2*n+1,400-n),0)),n=0..400):
> V:=series(V,q,350):

> jacprodmake(V2*aqprod(q,q^2,150),q,300);
"jacmake started with args", _A, 299
                                                         4
                                     JAC(0, 16, infinity)
      -----------------------------------------------------------------------------------
      JAC(1, 16, infinity) JAC(4, 16, infinity) JAC(6, 16, infinity) JAC(7, 16, infinity)


SEE ALSO :  jac2prod