% Test file for the REDUCE package QSUM
%
% Copyright (c) Wolfram Koepf, Harald Boeing, Konrad-Zuse-Zentrum Berlin, 1997
%
% Implementation of the q-Gosper and q-Zeilberger algorithms
%
% Reference:
%
% Koornwinder, T. H.:
% On Zeilberger's algorithm and its q-analogue: a rigorous description.
% J. of Comput. and Appl. Math. 48, 1993, 91-111.
%
% Some examples are from
%
% Koekoek, R. and Swarttouw, R.F.:
% The Askey-scheme of Hypergeometric Orthogonal Polynomials and its q-analogue.
% Report 94-05, Technische Universiteit Delft, Faculty of Technical Mathematics
% and Informatics, Delft, 1994.
%
% Gasper, G. and Rahman, M.:
% Basic Hypergeometric Series.
% Encyclopedia of Mathematics and its Applications 35. 
% Ed. by G.-C. Rota, Cambridge University Press, London and New York, 1990.


% Results of manual qsum.tex
%
load qsum;


qgosper(qpochhammer(a,q,k)*q^k/qpochhammer(q,q,k),q,k);


   k
 (q *a - 1)*qpochhammer(a,q,k)
-------------------------------
  (a - 1)*qpochhammer(q,q,k)

qgosper(qpochhammer(a,q,k)*qpochhammer(a*q^2,q^2,k)*
        qpochhammer(q^(-n),q,k)*q^(n*k)/(qpochhammer(a,q^2,k)*
        qpochhammer(a*q^(n+1),q,k)*qpochhammer(q,q,k)),q,k);


     k*n   k          k    n               1                       2  2
( - q   *(q *a - 1)*(q  - q )*qpochhammer(----,q,k)*qpochhammer(a*q ,q ,k)
                                            n
                                           q

                         2*k          n                   n
 *qpochhammer(a,q,k))/((q   *a - 1)*(q  - 1)*qpochhammer(q *a*q,q,k)

                   2
   *qpochhammer(a,q ,k)*qpochhammer(q,q,k))

qgosper(qpochhammer(q^(-n),q,k)*z^k/qpochhammer(q,q,k)*z^n,q,k);


***** No q-hypergeometric antidifference exists. 

off qgosper_down;


qgosper(q^k*qbrackets(k,q),q,k);


     k           k
  - q *(q + 1 - q )*qbrackets(k,q)
-----------------------------------
       k
     (q  - 1)*(q + 1)*(q - 1)

on qgosper_down;


qgosper(q^k,q,k,0,n);


  n
 q *q - 1
----------
  q - 1

qsumrecursion(qpochhammer(q^(-n),q,k)*z^k/qpochhammer(q,q,k),q,k,n);


      n                     n
 - ((q  - z)*summ(n - 1) - q *summ(n))

on qsumrecursion_certificate;


proof:=qsumrecursion(qpochhammer(q^(-n),q,k)*z^k/qpochhammer(q,q,k),q,k,n);


                n                     n
proof := { - ((q  - z)*summ(n - 1) - q *summ(n)),

                k    n
            - (q  - q )*z
          ----------------,
                n
               q  - 1

            k              1
           z *qpochhammer(----,q,k)
                            n
                           q
          --------------------------,
              qpochhammer(q,q,k)

          k,

          downward_antidifference}

off qsumrecursion_certificate;


% proof of statement
lhside:= qsimpcomb(sub(summ(n)=part(proof,3),
summ(n-1)=sub(n=n-1,part(proof,3)),part(proof,1)));


            k   k   n         n                       1
           z *(q *(q  - z) + q *(z - 1))*qpochhammer(----,q,k)
                                                       n
                                                      q
lhside := -----------------------------------------------------
                         n
                       (q  - 1)*qpochhammer(q,q,k)

rhside:= qsimpcomb((part(proof,2)*part(proof,3)-
sub(k=k-1,part(proof,2)*part(proof,3))));


               k    k    n       n   k                    1
            - z *((q  - q )*z - q *(q  - 1))*qpochhammer(----,q,k)
                                                           n
                                                          q
rhside := ---------------------------------------------------------
                           n
                         (q  - 1)*qpochhammer(q,q,k)

qsimpcomb((rhside-lhside)/part(proof,3));


0

% proof done
operator qlaguerre, qcharlier;


% q-Laguerre polynomials, Koekoek, Swarttouw (3.21)
qsumrecursion(qpochhammer(q^(alpha+1),q,n)/qpochhammer(q,q,n),
   {q^(-n)}, {q^(alpha+1)}, q, -x*q^(n+alpha+1), qlaguerre(n));


           n       alpha + n   n
((q + 1 - q )*q - q         *(q *x + q))*qlaguerre(n - 1)

      alpha + n                           n
 + ((q          - q)*qlaguerre(n - 2) + (q  - 1)*qlaguerre(n))*q

% q-Charlier polynomials, Koekoek, Swarttouw (3.23) 
qsumrecursion({q^(-n),q^(-x)},{0},q,-q^(n+1)/a,qcharlier(n));


      x            n       n       2*n
 - ((q *((q + 1 - q )*a + q )*q - q   )*qcharlier(n - 1)

        x    n          n
     + q *((q  + a*q)*(q  - q)*qcharlier(n - 2) - qcharlier(n)*a*q))

% continuous q-Jacobi polynomials, Koekoek, Swarttouw (3.10)
%% on qsum_nullspace;
%% term:= qpochhammer(q^(alpha+1),q,n)/qpochhammer(q,q,n)*
%%    qphihyperterm({q^(-n),q^(n+alpha+beta+1),
%%    q^(alpha/2+1/4)*exp(I*theta), q^(alpha/2+1/4)*exp(-I*theta)},
%%    {q^(alpha+1), -q^((alpha+beta+1)/2), -q^((alpha+beta+2)/2)},
%%     q, q, k)$
%% qsumrecursion(term,q,k,n,2);
%% off qsum_nullspace;

 
% Some more qgosper results with proof
%
% Gasper, Rahman (2.3.4)
term:=qpochhammer(a,q,k)*qpochhammer(a*q^2,q^2,k)*qpochhammer(q^(-n),q,k)*
q^(n*k)/(qpochhammer(a,q^2,k)*qpochhammer(a*q^(n+1),q,k)*qpochhammer(q,q,k));


          k*n              1                       2  2
         q   *qpochhammer(----,q,k)*qpochhammer(a*q ,q ,k)*qpochhammer(a,q,k)
                            n
                           q
term := ----------------------------------------------------------------------
                         n                         2
            qpochhammer(q *a*q,q,k)*qpochhammer(a,q ,k)*qpochhammer(q,q,k)


result:=qgosper(qpochhammer(a,q,k)*qpochhammer(a*q^2,q^2,k)*
qpochhammer(q^(-n),q,k)*q^(n*k)/
(qpochhammer(a,q^2,k)*qpochhammer(a*q^(n+1),q,k)*qpochhammer(q,q,k)),q,k);


               k*n   k          k    n               1
result := ( - q   *(q *a - 1)*(q  - q )*qpochhammer(----,q,k)
                                                      n
                                                     q

                           2  2                           2*k          n
           *qpochhammer(a*q ,q ,k)*qpochhammer(a,q,k))/((q   *a - 1)*(q  - 1)

                           n                         2
             *qpochhammer(q *a*q,q,k)*qpochhammer(a,q ,k)*qpochhammer(q,q,k))


qsimpcomb(result-sub(k=k-1,result)-term);


0


% Gasper, Rahman (3.8.16)
term:=(1-a*c*q^(4*k))*(1-b/c*q^(-2*k))*qpochhammer(a,q,k)*qpochhammer(b,q,k)*
qpochhammer(q^(-3*n),q^3,k)*qpochhammer(a*c^2/b*q^(3*n),q^3,k)*q^(3*k)/
((1-a*c)*(1-b/c)*qpochhammer(c*q^3,q^3,k)*qpochhammer(a*c/b*q^3,q^3,k)*
qpochhammer(a*c*q^(3*n+1),q,k)*qpochhammer(b/c*q^(1-3*n),q,k));


                          3*n    2
          k              q   *a*c    3                  1     3
term := (q *qpochhammer(-----------,q ,k)*qpochhammer(------,q ,k)
                             b                          3*n
                                                       q

         *qpochhammer(a,q,k)*qpochhammer(b,q,k)

                                                                       3
               6*k    2    4*k          2*k                       a*c*q    3
         *( - q   *a*c  + q   *a*b*c + q   *c - b))/(qpochhammer(--------,q ,k)
                                                                    b

                          b*q                      3*n
           *qpochhammer(--------,q,k)*qpochhammer(q   *a*c*q,q,k)
                          3*n
                         q   *c

                           3  3                2
           *qpochhammer(c*q ,q ,k)*(a*b*c - a*c  - b + c))


result:=qgosper((1-a*c*q^(4*k))*(1-b/c*q^(-2*k))*qpochhammer(a,q,k)*
qpochhammer(b,q,k)*qpochhammer(q^(-3*n),q^3,k)*qpochhammer(a*c^2/
b*q^(3*n),q^3,k)*q^(3*k)/((1-a*c)*(1-b/c)*qpochhammer(c*q^3,q^3,k)*
qpochhammer(a*c/b*q^3,q^3,k)*qpochhammer(a*c*q^(3*n+1),q,k)*
qpochhammer(b/c*q^(1-3*n),q,k)),q,k);


                3*k + 3*n    2        2*k    k + n    2*n    k          k
result := ( - (q         *a*c  - b)*(q    + q      + q   )*(q *a - 1)*(q *b - 1)

                                    3*n    2
              k    n               q   *a*c    3                  1     3
           *(q  - q )*qpochhammer(-----------,q ,k)*qpochhammer(------,q ,k)
                                       b                          3*n
                                                                 q

                                                        3*n
           *qpochhammer(a,q,k)*qpochhammer(b,q,k)*c)/((q   *a*c - b)

                                                               3
                3*n                                       a*c*q    3
             *(q   *c - 1)*(a*c - 1)*(b - c)*qpochhammer(--------,q ,k)
                                                            b

                            b*q                      3*n
             *qpochhammer(--------,q,k)*qpochhammer(q   *a*c*q,q,k)
                            3*n
                           q   *c

                             3  3
             *qpochhammer(c*q ,q ,k))


qsimpcomb(result-sub(k=k-1,result)-term);


0


end;

Tested on x86_64-pc-windows CSL
Time (counter 1): 109 ms

End of Lisp run after 0.10+0.06 seconds
real 0.32
user 0.00
sys 0.06
