File r38/log/ztrans.rlg artifact e050a4c493 part of check-in e1a8550313


Tue Apr 15 00:36:13 2008 run on win32

*** binomial already defined as operator 

*** ~f already defined as operator 
% test file for ztrans package
% 
operator f;


operator g;


operator h;



% Examples for Z transformation
ztrans(1,n,z);


   z
-------
 z - 1

ztrans(a,n,z);


  a*z
-------
 z - 1

ztrans((-1)^n,n,z);


   z
-------
 z + 1

ztrans(n,n,z);


      z
--------------
  2
 z  - 2*z + 1

ztrans(n^2,n,z);


      z*(z + 1)
---------------------
  3      2
 z  - 3*z  + 3*z - 1

ztrans(n^k,n,z);


        k
ztrans(n ,n,z)

% should be output=input
ztrans((-1)^n*n^2,n,z);


    z*( - z + 1)
---------------------
  3      2
 z  + 3*z  + 3*z + 1

ztrans(binomial(n,m),n,z);


        z
------------------
        m
 (z - 1) *(z - 1)

ztrans((-1)^n*binomial(n,m),n,z);


          z
---------------------
           m
 ( - z - 1) *(z + 1)

ztrans(binomial(n+k,m),n,z);


        k
       z *z
------------------
        m
 (z - 1) *(z - 1)

ztrans(a^n,n,z);


  - z
-------
 a - z

ztrans(a^(n-1),n,z);


    - z
-----------
 a*(a - z)

ztrans(a^(n+k),n,z);


     k
  - a *z
---------
  a - z

ztrans((-1)^n*a^n,n,z);


   z
-------
 a + z

ztrans(1-a^n,n,z);


    z*(a - 1)
------------------
            2
 a*z - a - z  + z

ztrans(n*a^n,n,z);


       a*z
-----------------
  2            2
 a  - 2*a*z + z

ztrans(n^3*a^n,n,z);


              2            2
        a*z*(a  + 4*a*z + z )
-------------------------------------
  4      3        2  2        3    4
 a  - 4*a *z + 6*a *z  - 4*a*z  + z

ztrans(binomial(n,m)*a^n,n,z);


         m
      - a *z
------------------
        m
 (z - a) *(a - z)

ztrans(1/(n+1),n,z);


       z
log(-------)*z
     z - 1

ztrans(1/(n+2),n,z);


          z
z*(log(-------)*z - 1)
        z - 1

ztrans((-1)^(n)/(n+1),n,z);


          z
 - log(-------)*z
        z + 1

ztrans((-1)^(n)/(n+2),n,z);


          z
z*(log(-------)*z + 1)
        z + 1

ztrans(a^(n-1)/(n+1),n,z);


       - z
 log(-------)*z
      a - z
----------------
        2
       a

ztrans(a^(n+k)/(n+1),n,z);


  k       - z
 a *log(-------)*z
         a - z
-------------------
         a

ztrans(a^n/factorial(n),n,z);


 a/z
e

ztrans((n+1)*a^n/factorial(n),n,z);


  a/z
 e   *(a + z)
--------------
      z

ztrans(1/factorial(n-1),n,z);


                                           1
***** ERROR: zero divisor in sum(---------------------,n,0,infinity)
                                   n
                                  z *factorial(n - 1)

% ERROR message o.k.
ztrans((-1)^n/factorial(2*n+1),n,z);


                1
sqrt(z)*sin(---------)
             sqrt(z)

ztrans((-1)^n/factorial(2*n),n,z);


        1
cos(---------)
     sqrt(z)

ztrans(1/factorial(2*n+1),n,z);


                 1
sqrt(z)*sinh(---------)
              sqrt(z)

ztrans(1/factorial(2*n-1),n,z);


                1
ztrans(--------------------,n,z)
        factorial(2*n - 1)

ztrans(1/factorial(2*n+3),n,z);


                    1
z*(sqrt(z)*sinh(---------) - 1)
                 sqrt(z)

ztrans(1/factorial(2*n),n,z);


         1
cosh(---------)
      sqrt(z)

ztrans(1/factorial(2*n+2),n,z);


            1
z*(cosh(---------) - 1)
         sqrt(z)

ztrans(a^n/factorial(2*n+1),n,z);


               sqrt(a)
 sqrt(z)*sinh(---------)
               sqrt(z)
-------------------------
         sqrt(a)

ztrans(a^n/factorial(2*n),n,z);


      sqrt(a)
cosh(---------)
      sqrt(z)

ztrans(e^(a*n),n,z);


   - z
--------
  a
 e  - z

ztrans(e^(a*(n+k)),n,z);


     a*k
  - e   *z
-----------
   a
  e  - z

ztrans(sinh(a*n),n,z);


      - sinh(a)*z
----------------------
                2
 2*cosh(a)*z - z  - 1

ztrans(cosh(a*n),n,z);


   z*(cosh(a) - z)
----------------------
                2
 2*cosh(a)*z - z  - 1

ztrans(sinh(a*n+p),n,z);


  - z*(sinh(a - p) + sinh(p)*z)
--------------------------------
                     2
      2*cosh(a)*z - z  - 1

ztrans(cosh(a*n+p),n,z);


 z*(cosh(a - p) - cosh(p)*z)
-----------------------------
                   2
    2*cosh(a)*z - z  - 1

ztrans(a^n*sinh(a*n),n,z);


      - sinh(a)*a*z
-------------------------
                  2    2
 2*cosh(a)*a*z - a  - z

ztrans(a^n*cosh(a*n),n,z);


    z*(cosh(a)*a - z)
-------------------------
                  2    2
 2*cosh(a)*a*z - a  - z

ztrans(n*sinh(a*n),n,z);


                                 2
                     sinh(a)*z*(z  - 1)
------------------------------------------------------------
          2  2              3                  4      2
 4*cosh(a) *z  - 4*cosh(a)*z  - 4*cosh(a)*z + z  + 2*z  + 1

ztrans(n*cosh(a*n),n,z);


                           2
               z*(cosh(a)*z  + cosh(a) - 2*z)
------------------------------------------------------------
          2  2              3                  4      2
 4*cosh(a) *z  - 4*cosh(a)*z  - 4*cosh(a)*z + z  + 2*z  + 1

ztrans(n^2*a^n*sinh(b*n),n,z);


                          2  4  2            2  2  4               3  3    6
(sinh(b)*a*z*( - 4*cosh(b) *a *z  - 4*cosh(b) *a *z  + 16*cosh(b)*a *z  + a

                    4  2      2  4    6              4  4  4             3  5  3
               - 5*a *z  - 5*a *z  + z ))/(16*cosh(b) *a *z  - 32*cosh(b) *a *z

                3  3  5             2  6  2             2  4  4
    - 32*cosh(b) *a *z  + 24*cosh(b) *a *z  + 48*cosh(b) *a *z

                2  2  6              7                 5  3               3  5
    + 24*cosh(b) *a *z  - 8*cosh(b)*a *z - 24*cosh(b)*a *z  - 24*cosh(b)*a *z

                   7    8      6  2      4  4      2  6    8
    - 8*cosh(b)*a*z  + a  + 4*a *z  + 6*a *z  + 4*a *z  + z )

ztrans(sin(b*n),n,z);


      - sin(b)*z
---------------------
               2
 2*cos(b)*z - z  - 1

ztrans(cos(b*n),n,z);


   z*(cos(b) - z)
---------------------
               2
 2*cos(b)*z - z  - 1

ztrans(sin(b*n+p),n,z);


  - z*(sin(b - p) + sin(p)*z)
------------------------------
                   2
     2*cos(b)*z - z  - 1

ztrans(cos(b*n+p),n,z);


 z*(cos(b - p) - cos(p)*z)
---------------------------
                  2
    2*cos(b)*z - z  - 1

ztrans(e^(a*n)*sin(b*n),n,z);


          a
       - e *sin(b)*z
---------------------------
    a             2*a    2
 2*e *cos(b)*z - e    - z

ztrans(e^(a*n)*cos(b*n),n,z);


         a
     z*(e *cos(b) - z)
---------------------------
    a             2*a    2
 2*e *cos(b)*z - e    - z

ztrans((-1)^n*e^(a*n)*sin(b*n),n,z);


          a
       - e *sin(b)*z
---------------------------
    a             2*a    2
 2*e *cos(b)*z + e    + z

ztrans((-1)^n*e^(a*n)*cos(b*n),n,z);


         a
     z*(e *cos(b) + z)
---------------------------
    a             2*a    2
 2*e *cos(b)*z + e    + z

ztrans(n*sin(b*n),n,z);


                               2
                    sin(b)*z*(z  - 1)
---------------------------------------------------------
         2  2             3                 4      2
 4*cos(b) *z  - 4*cos(b)*z  - 4*cos(b)*z + z  + 2*z  + 1

ztrans(n*cos(b*n),n,z);


                         2
              z*(cos(b)*z  + cos(b) - 2*z)
---------------------------------------------------------
         2  2             3                 4      2
 4*cos(b) *z  - 4*cos(b)*z  - 4*cos(b)*z + z  + 2*z  + 1

ztrans(n^2*a^n*sin(b*n),n,z);


                        2  4  2           2  2  4              3  3    6
(sin(b)*a*z*( - 4*cos(b) *a *z  - 4*cos(b) *a *z  + 16*cos(b)*a *z  + a

                   4  2      2  4    6             4  4  4            3  5  3
              - 5*a *z  - 5*a *z  + z ))/(16*cos(b) *a *z  - 32*cos(b) *a *z

               3  3  5            2  6  2            2  4  4            2  2  6
    - 32*cos(b) *a *z  + 24*cos(b) *a *z  + 48*cos(b) *a *z  + 24*cos(b) *a *z

                7                5  3              3  5               7    8
    - 8*cos(b)*a *z - 24*cos(b)*a *z  - 24*cos(b)*a *z  - 8*cos(b)*a*z  + a

         6  2      4  4      2  6    8
    + 4*a *z  + 6*a *z  + 4*a *z  + z )

ztrans(cos(b*(n+1))/(n+1),n,z);


                  z
log(------------------------------)*z
                           2
     sqrt( - 2*cos(b)*z + z  + 1)

ztrans(sin(b*(n+1))/(n+1),n,z);


           sin(b)
 - atan(------------)*z
         cos(b) - z

ztrans(cos(b*(n+2))/(n+2),n,z);


                                 z
z*( - cos(b) + log(------------------------------)*z)
                                          2
                    sqrt( - 2*cos(b)*z + z  + 1)

ztrans((-1)^(n)*cos(b*(n+1))/(n+1),n,z);


                       2    3
        sqrt(2*cos(b)*z  + z  + 1)
 - log(----------------------------)*z
                 sqrt(z)

ztrans((-1)^(n)*sin(b*(n+1))/(n+1),n,z);


        sin(b)
atan(------------)*z
      cos(b) + z

ztrans(cos(b*n)/factorial(n),n,z);


 cos(b)/z      sin(b)
e        *cos(--------)
                 z

ztrans(sin(b*n)/factorial(n),n,z);


 cos(b)/z      sin(b)
e        *sin(--------)
                 z

ztrans(a*f(n)+b*g(n)+c*h(n),n,z);


ztrans(f(n),n,z)*a + ztrans(g(n),n,z)*b + ztrans(h(n),n,z)*c

ztrans(sum(f(k)*g(n-k),k,0,n),n,z);


ztrans(f(n),n,z)*ztrans(g(n),n,z)

ztrans(sum(f(k),k,0,n),n,z);


 ztrans(f(n),n,z)*z
--------------------
       z - 1

ztrans(sum(f(k),k,-2,n),n,z);


                                2
(z*( - f(-1)*z + f(-1) - f(-2)*z  + f(-2) + ztrans(f(n - 2),n,z)

                             2
     + ztrans(f(n - 2),n,z)*z  - ztrans(f(n - 2),n,z)))/(z - 1)

ztrans(sum(f(k),k,3,n),n,z);


                          2                     2
  - f(2) - f(1)*z - f(0)*z  + ztrans(f(n),n,z)*z
--------------------------------------------------
                    z*(z - 1)

ztrans(sum(f(k),k,0,n+2),n,z);


                             2                                               2
(z*( - f(1)*z + f(1) - f(0)*z  + f(0) + ztrans(f(n),n,z) + ztrans(f(n),n,z)*z

     - ztrans(f(n),n,z)))/(z - 1)

ztrans(sum(f(k),k,0,n-3),n,z);


                   2                     2
 ztrans(f(n),n,z)*z  - ztrans(f(n),n,z)*z  + ztrans(f(n),n,z)
--------------------------------------------------------------
                           2
                          z *(z - 1)

ztrans(sum(f(k),k,-2,n+3),n,z);


                             2                3                 4
(z*( - f(2)*z + f(2) - f(1)*z  + f(1) - f(0)*z  + f(0) - f(-1)*z  + f(-1)

              5                                                        5
     - f(-2)*z  + f(-2) + ztrans(f(n - 2),n,z) + ztrans(f(n - 2),n,z)*z

     - ztrans(f(n - 2),n,z)))/(z - 1)

ztrans(sum(1/factorial(k),k,0,n),n,z);


  1/z
 e   *z
--------
 z - 1

ztrans(sum(1/factorial(k+2),k,0,n),n,z);


  2   1/z
 z *(e   *z - z - 1)
---------------------
        z - 1

ztrans(n^2*sum(1/factorial(k),k,0,n),n,z);


  1/z     3      2
 e   *(2*z  + 2*z  - 3*z + 1)
------------------------------
       3      2
   z*(z  - 3*z  + 3*z - 1)

ztrans(sum(n^2/factorial(k),k,0,n),n,z);


  1/z     3      2
 e   *(2*z  + 2*z  - 3*z + 1)
------------------------------
       3      2
   z*(z  - 3*z  + 3*z - 1)

ztrans(sum(1/k,k,0,n),n,z);


                                   1
***** ERROR: zero divisor in sum(------,n,0,infinity)
                                   n
                                  z *n

% ERROR o.k.
ztrans(sum(1/(k+1),k,0,n),n,z);


        z      2
 log(-------)*z
      z - 1
-----------------
      z - 1

ztrans(sum(1/(k+3),k,0,n),n,z);


  2           z      2
 z *(2*log(-------)*z  - 2*z - 1)
            z - 1
----------------------------------
            2*(z - 1)

ztrans(f(n+k),n,z);


ztrans(f(k + n),n,z)

% output=input
ztrans(f(n+2),n,z);


z*( - f(1) - f(0)*z + ztrans(f(n),n,z)*z)

ztrans(f(n-k),n,z);


ztrans(f( - k + n),n,z)

% output=input
ztrans(f(n-3),n,z);


ztrans(f(n - 3),n,z)

% output=input
ztrans(a^n*f(n),n,z);


               z
ztrans(f(n),n,---)
               a

ztrans(n*f(n),n,z);


 - df(ztrans(f(n),n,z),z)*z

ztrans(1/a^n,n,z);


   a*z
---------
 a*z - 1

ztrans(1/a^(n+1),n,z);


    z
---------
 a*z - 1

ztrans(1/a^(n-1),n,z);


   2
  a *z
---------
 a*z - 1

ztrans(2*n+n^2-3/4*n^3,n,x);


            2
      x*(9*x  - 28*x + 1)
--------------------------------
     4      3      2
 4*(x  - 4*x  + 6*x  - 4*x + 1)

ztrans(n^2*cos(n*x),n,z);


               3  4           3  2           6             4             2
(z*( - 4*cos(x) *z  + 4*cos(x) *z  + cos(x)*z  + 9*cos(x)*z  - 9*cos(x)*z

                   5                   4  4            3  5            3  3
     - cos(x) - 4*z  + 4*z))/(16*cos(x) *z  - 32*cos(x) *z  - 32*cos(x) *z

               2  6            2  4            2  2             7              5
    + 24*cos(x) *z  + 48*cos(x) *z  + 24*cos(x) *z  - 8*cos(x)*z  - 24*cos(x)*z

                 3                 8      6      4      2
    - 24*cos(x)*z  - 8*cos(x)*z + z  + 4*z  + 6*z  + 4*z  + 1)

ztrans((1+n)^2*f(n),n,z);


                          2
df(ztrans(f(n),n,z),z,2)*z  - df(ztrans(f(n),n,z),z)*z + ztrans(f(n),n,z)

ztrans(n^2*f(n),n,z);


z*(df(ztrans(f(n),n,z),z,2)*z + df(ztrans(f(n),n,z),z))

ztrans(n/factorial(n),n,z);


  1/z
 e
------
  z

ztrans(n^2/factorial(n),n,z);


  1/z
 e   *(z + 1)
--------------
       2
      z

ztrans(a^n/factorial(n),n,z);


 a/z
e

ztrans(1/(a^n*factorial(n)),n,z);


 1/(a*z)
e

ztrans(sum(f(k)*g(n-k),k,0,n),n,z);


ztrans(f(n),n,z)*ztrans(g(n),n,z)

ztrans(sum(f(k),k,0,n-1),n,z);


 ztrans(f(n),n,z)
------------------
      z - 1

ztrans(sum(f(k),k,0,n),n,z);


 ztrans(f(n),n,z)*z
--------------------
       z - 1

ztrans(sum(1/factorial(k),k,0,n),n,z);


  1/z
 e   *z
--------
 z - 1

ztrans(sum(k/factorial(k),k,0,n),n,z);


  1/z
 e
-------
 z - 1

ztrans(sum(a^k*k^2/factorial(k),k,0,n),n,z);


  a/z
 e   *a*(a + z)
----------------
   z*(z - 1)

ztrans(a^n*f(n),n,z);


               z
ztrans(f(n),n,---)
               a

ztrans(binomial(n,k),n,z);


        z
------------------
        k
 (z - 1) *(z - 1)

ztrans(1/(n+1),n,z);


       z
log(-------)*z
     z - 1

ztrans(n/factorial(2*n+1),n,z);


                  1                 1
 sqrt(z)*cosh(---------) - sinh(---------)*z
               sqrt(z)           sqrt(z)
---------------------------------------------
                  2*sqrt(z)

ztrans(a^n*sin(n*x+y),n,z);


  - z*(sin(x - y)*a + sin(y)*z)
--------------------------------
                     2    2
     2*cos(x)*a*z - a  - z

ztrans(n^3*sin(n*x+y),n,z);


            3         4           2             4           2             2
(z*(8*cos(x) *sin(y)*z  + 4*cos(x) *sin(x - y)*z  - 4*cos(x) *sin(x - y)*z

                2         5            2         3                        5
     + 16*cos(x) *sin(y)*z  - 16*cos(x) *sin(y)*z  + 8*cos(x)*sin(x - y)*z

                                                6                     4
     - 8*cos(x)*sin(x - y)*z + 2*cos(x)*sin(y)*z  - 36*cos(x)*sin(y)*z

                         2               6                  4                  2
     + 10*cos(x)*sin(y)*z  + sin(x - y)*z  - 23*sin(x - y)*z  + 23*sin(x - y)*z

                              5              3                          4  4
     - sin(x - y) - 8*sin(y)*z  + 32*sin(y)*z  - 8*sin(y)*z))/(16*cos(x) *z

               3  5            3  3            2  6            2  4
    - 32*cos(x) *z  - 32*cos(x) *z  + 24*cos(x) *z  + 48*cos(x) *z

               2  2             7              5              3
    + 24*cos(x) *z  - 8*cos(x)*z  - 24*cos(x)*z  - 24*cos(x)*z  - 8*cos(x)*z

       8      6      4      2
    + z  + 4*z  + 6*z  + 4*z  + 1)

ztrans((n+1)/factorial(n),n,z);


  1/z
 e   *(z + 1)
--------------
      z

ztrans(factorial(n)/(factorial(k)*factorial(n-k)),n,z);


        z
------------------
        k
 (z - 1) *(z - 1)


% Examples for inverse Z transformation
invztrans(z/(z-1),z,n);


      2*n
( - 1)

invztrans(z/(z+1),z,n);


      n
( - 1)

invztrans(z/(z-1)^2,z,n);


n

invztrans(z*(z+1)/(z-1)^3,z,n);


 2
n

invztrans(z/(z-1)^m,z,n);


       2*n
 ( - 1)   *binomial(n,m - 1)
-----------------------------
                2*m
          ( - 1)

% invztrans(z/(z-1)^(m+1),z,n);
% not yet supported
invztrans(z/(z-1)^4,z,n);


     2
 n*(n  - 3*n + 2)
------------------
        6

invztrans((-1)^m*z/(z+1)^m,z,n);


                 m
           ( - 1) *z
invztrans(-----------,z,n)
                  m
           (z + 1)

% not yet supported
invztrans(z/(z+1)^4,z,n);


       n        2
 ( - 1) *n*( - n  + 3*n - 2)
-----------------------------
              6

% invztrans(z^(k+1)/(z-1)^(m+1),z,n);
% not yet supported
invztrans(z^4/(z-1)^m,z,n);


       2*n
 ( - 1)   *binomial(n + 3,m - 1)
---------------------------------
                  2*m
            ( - 1)

% invztrans(z^4/(z-1)^(m+1),z,n);
% not yet supported
% invztrans(z^4/(z-1)^m,z,n);
% not yet supported
% invztrans(z^(k+1)/(z-1)^5,z,n);
% not yet supported
invztrans(z^3/(z-a)^4,z,n);


  n     2
 a *n*(n  + 3*n + 2)
---------------------
         6*a

invztrans(z/(z-a),z,n);


 n
a

invztrans(z/(z+a),z,n);


 n       n
a *( - 1)

invztrans(z*(1-a)/((z-1)*(z-a)),z,n);


    n
 - a  + 1

invztrans(z*a/(z-a)^2,z,n);


 n
a *n

invztrans(z*3/(z-3)^2,z,n);


 n
3 *n

% invztrans(a^m*z/(z-a)^(m+1),z,n);
% not yet supported
% invztrans(a^m*z/(z-a)^m,z,n);
% not yet supported
% invztrans(4^m*z/(z-4)^(m+1),z,n);
% not yet supported
invztrans(a^3*z/(z-a)^5,z,n);


  n     3      2
 a *n*(n  - 6*n  + 11*n - 6)
-----------------------------
            24*a

invztrans(z*log(z/(z-1)),z,n);


       2*n
 ( - 1)
-----------
   n + 1

invztrans(z*log(1+1/z),z,n);


       n
 ( - 1)
---------
  n + 1

invztrans(z*log(z/(z-a)),z,n);


  n       2*n
 a *( - 1)   *a
----------------
     n + 1

invztrans(e^(a/z),z,n);


       n
      a
--------------
 factorial(n)

invztrans(e^(1/(a*z)),z,n);


        1
-----------------
  n
 a *factorial(n)

invztrans((1+a/z)*e^(a/z),z,n);


   n
  a *(n + 1)
--------------
 factorial(n)

invztrans(e^(a/z)*(a+z)/z,z,n);


   n
  a *(n + 1)
--------------
 factorial(n)

invztrans(sqrt(z)*sin(1/sqrt(z)),z,n);


            n
      ( - 1)
--------------------
 factorial(2*n + 1)

invztrans(cos(1/sqrt(z)),z,n);


          n
    ( - 1)
----------------
 factorial(2*n)

invztrans(sqrt(z)*sinh(1/sqrt(z)),z,n);


         1
--------------------
 factorial(2*n + 1)

invztrans(cosh(1/sqrt(z)),z,n);


       1
----------------
 factorial(2*n)

invztrans(sqrt(z/a)*sinh(sqrt(a/z)),z,n);


          n
         a
--------------------
 factorial(2*n + 1)

invztrans(cosh(sqrt(a/z)),z,n);


        n
       a
----------------
 factorial(2*n)

invztrans(z/(z-e^a),z,n);


 a*n
e

invztrans(z*sinh(a)/(z^2-2*z*cosh(a)+1),z,n);


sinh(a*n)

invztrans(z*(z-cosh(a))/(z^2-2*z*cosh(a)+1),z,n);


cosh(a*n)

invztrans(z*(z*sinh(p)+sinh(a-p))/(z^2-2*z*cosh(a)+1),z,n);


 cosh(a*n)*sinh(a)*sinh(p) + cosh(a)*sinh(a*n)*sinh(p) + sinh(a - p)*sinh(a*n)
-------------------------------------------------------------------------------
                                    sinh(a)

% trigsimp(ws);
% trigsimp(ws,combine);
invztrans(z*(z*cosh(p)-cosh(a-p))/(z^2-2*z*cosh(a)+1),z,n);


( - cosh(a - p)*sinh(a*n) + cosh(a*n)*cosh(p)*sinh(a)

  + cosh(a)*cosh(p)*sinh(a*n))/sinh(a)

% trigsimp(ws);
% trigsimp(ws,combine);
invztrans(a*z*sinh(a)/(z^2-2*a*z*cosh(a)+a^2),z,n);


 n
a *sinh(a*n)

invztrans(z*(z-a*cosh(a))/(z^2-2*a*z*cosh(a)+a^2),z,n);


 n
a *cosh(a*n)

invztrans(z*(z^2-1)*sinh(a)/(z^2-2*z*cosh(a)+1)^2,z,n);


                  2
 sinh(a*n)*sinh(a) *n
----------------------
            2
     cosh(a)  - 1

% trigsimp(ws);
invztrans(z*((z^2+1)*cosh(a)-2*z)/(z^2-2*z*cosh(a)+1)^2,z,n);


cosh(a*n)*n

invztrans(z*sin(b)/(z^2-2*z*cos(b)+1),z,n);


sin(b*n)

invztrans(z*(z-cos(b))/(z^2-2*z*cos(b)+1),z,n);


cos(b*n)

invztrans(z*(z*sin(p)+sin(b-p))/(z^2-2*z*cos(b)+1),z,n);


 cos(b*n)*sin(b)*sin(p) + cos(b)*sin(b*n)*sin(p) + sin(b - p)*sin(b*n)
-----------------------------------------------------------------------
                                sin(b)

% trigsimp(ws);
% trigsimp(ws,combine);
invztrans(z*(z*cos(p)-cos(b-p))/(z^2-2*z*cos(b)+1),z,n);


  - cos(b - p)*sin(b*n) + cos(b*n)*cos(p)*sin(b) + cos(b)*cos(p)*sin(b*n)
--------------------------------------------------------------------------
                                  sin(b)

% trigsimp(ws);
% trigsimp(ws,combine);
invztrans(z*e^(a)*sin(b)/(z^2-2*z*e^a*cos(b)+e^(2*a)),z,n);


 a*n
e   *sin(b*n)

invztrans(z*(z-e^a*cos(b))/(z^2-2*z*e^a*cos(b)+e^(2*a)),z,n);


 a*n
e   *cos(b*n)

invztrans(-z*e^a*sin(b)/(z^2+2*z*e^a*cos(b)+e^(2*a)),z,n);


 a*n       n
e   *( - 1) *sin(b*n)

invztrans(z*(z+e^a*cos(b))/(z^2+2*z*e^a*cos(b)+e^(2*a)),z,n);


 a*n       n
e   *( - 1) *cos(b*n)

invztrans(z*(z^2-1)*sin(b)/(z^2-2*z*cos(b)+1)^2,z,n);


            2
(sqrt(cos(b)  - 1)*sin(b)*n

                           2      n                        2      n
 *( - (cos(b) - sqrt(cos(b)  - 1))  + (cos(b) + sqrt(cos(b)  - 1)) ))/(2

           2
   *(cos(b)  - 1))

% trigsimp(ws,expon);
% trigsimp(ws,trig);
invztrans(z*((z^2+1)*cos(b)-2*z)/(z^2-2*z*cos(b)+1)^2,z,n);


                         2      n                        2      n
 n*((cos(b) - sqrt(cos(b)  - 1))  + (cos(b) + sqrt(cos(b)  - 1)) )
-------------------------------------------------------------------
                                 2

% trigsimp(ws,expon);
% trigsimp(ws,trig);
invztrans(z*log(z/sqrt(z^2-2*z*cos(b)+1)),z,n);


 cos(b*n + b)
--------------
    n + 1

invztrans(z*atan(sin(b)/(z-cos(b))),z,n);


 sin(b*n + b)
--------------
    n + 1

invztrans(z*log(sqrt(z^2+2*z*cos(b)+1)/z),z,n);


       n
 ( - 1) *cos(b*n + b)
----------------------
        n + 1

invztrans(z*atan(sin(b)/(z+cos(b))),z,n);


       n
 ( - 1) *sin(b*n + b)
----------------------
        n + 1

invztrans(cos(sin(b)/z)*e^(cos(b)/z),z,n);


   cos(b*n)
--------------
 factorial(n)

invztrans(sin(sin(b)/z)*e^(cos(b)/z),z,n);


   sin(b*n)
--------------
 factorial(n)

invztrans((f+a*z+b*z^2)/(c+d*z+e*z^2),z,n);


                     2      n                  2        n
(2*(sqrt( - 4*c*e + d ) + d) *sqrt( - 4*c*e + d )*( - 1) *a*c*e

                      2      n                  2        n
  - (sqrt( - 4*c*e + d ) + d) *sqrt( - 4*c*e + d )*( - 1) *b*c*d

                      2      n                  2        n
  - (sqrt( - 4*c*e + d ) + d) *sqrt( - 4*c*e + d )*( - 1) *d*e*f

                        2      n       n    2
  + 4*(sqrt( - 4*c*e + d ) + d) *( - 1) *b*c *e

                      2      n       n      2
  - (sqrt( - 4*c*e + d ) + d) *( - 1) *b*c*d

                        2      n       n    2
  - 4*(sqrt( - 4*c*e + d ) + d) *( - 1) *c*e *f

                      2      n       n  2
  + (sqrt( - 4*c*e + d ) + d) *( - 1) *d *e*f

                        2      n                  2
  - 2*(sqrt( - 4*c*e + d ) - d) *sqrt( - 4*c*e + d )*a*c*e

                      2      n                  2
  + (sqrt( - 4*c*e + d ) - d) *sqrt( - 4*c*e + d )*b*c*d

                      2      n                  2
  + (sqrt( - 4*c*e + d ) - d) *sqrt( - 4*c*e + d )*d*e*f

                        2      n    2                       2      n      2
  + 4*(sqrt( - 4*c*e + d ) - d) *b*c *e - (sqrt( - 4*c*e + d ) - d) *b*c*d

                        2      n    2                       2      n  2
  - 4*(sqrt( - 4*c*e + d ) - d) *c*e *f + (sqrt( - 4*c*e + d ) - d) *d *e*f)/(2

     n  n               2
   *e *2 *c*e*(4*c*e - d ))


% Example 1 in Bronstein/Semendjajew, p. 651

f(0):=0;


f(0) := 0

f(1):=0;


f(1) := 0

f(2):=9;


f(2) := 9

f(3):=-2;


f(3) := -2

f(4):=23;


f(4) := 23

equation:=ztrans(f(n+5)-2*f(n+3)+2*f(n+2)-3*f(n+1)+2*f(n),n,z);


                              5                       3                       2
equation := ztrans(f(n),n,z)*z  - 2*ztrans(f(n),n,z)*z  + 2*ztrans(f(n),n,z)*z

                                                              3      2
             - 3*ztrans(f(n),n,z)*z + 2*ztrans(f(n),n,z) - 9*z  + 2*z  - 5*z

ztransresult:=solve(equation,ztrans(f(n),n,z));


                                             2
                                       z*(9*z  - 2*z + 5)
ztransresult := {ztrans(f(n),n,z)=----------------------------}
                                    5      3      2
                                   z  - 2*z  + 2*z  - 3*z + 2

result:=invztrans(part(first(ztransresult),2),z,n);


               n       n           n  n    n
            - i *( - 1)  + 2*( - 1) *2  - i  + 4*n
result := -----------------------------------------
                              2


% Example 2 in Bronstein/Semendjajew, p. 651

clear(f);


operator f;


f(0):=0;


f(0) := 0

f(1):=1;


f(1) := 1

equation:=ztrans(f(n+2)-4*f(n+1)+3*f(n)-1,n,z);


                               3                       2
equation := (ztrans(f(n),n,z)*z  - 5*ztrans(f(n),n,z)*z  + 7*ztrans(f(n),n,z)*z

                                      2
              - 3*ztrans(f(n),n,z) - z )/(z - 1)

ztransresult:=solve(equation,ztrans(f(n),n,z));


                                            2
                                           z
ztransresult := {ztrans(f(n),n,z)=---------------------}
                                    3      2
                                   z  - 5*z  + 7*z - 3

result:=invztrans(part(first(ztransresult),2),z,n);


              n
           3*3  - 2*n - 3
result := ----------------
                 4


% Other example:

clear(f);


operator f;


f(0):=1;


f(0) := 1

f(1):=1;


f(1) := 1

operator tmp;


equation:=ztrans((n+1)*f(n+1)-f(n),n,z);


                                        2
equation :=  - (df(ztrans(f(n),n,z),z)*z  + ztrans(f(n),n,z))

equation:=sub(ztrans(f(n),n,z)=tmp(z),equation);


                              2
equation :=  - (df(tmp(z),z)*z  + tmp(z))

load_package odesolve;


*** airy_ai already defined as operator 

*** airy_bi already defined as operator 

*** ci already defined as operator 

*** si already defined as operator 

oderesult:=odesolve(equation,tmp(z),z);


                      1/z
oderesult := {tmp(z)=e   *arbconst(1)}

preresult:=invztrans(part(first(oderesult),2),z,n);


              arbconst(1)
preresult := --------------
              factorial(n)

solveresult:=
solve({sub(n=0,preresult)=f(0),sub(n=1,preresult)=f(1)},arbconst(1));


solveresult := {arbconst(1)=1}

result:=preresult where solveresult;


      1
--------------
 factorial(n)


end;


Time for test: 2380 ms, plus GC time: 179 ms


REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]