> restart:
> with(Statistics):
> gamma_:=RandomVariable(Gamma(1/lambda,k)):
> assume(u>0);
> pdf:=subs(u=x-_gamma,PDF(gamma_,u));
> cdf:=subs(u=x-_gamma,CDF(gamma_,u)):
> cdf2:=simplify(convert(cdf,hypergeom),symbolic);
> cf:=subs(u=x,exp(-I*_gamma)*CharacteristicFunction(gamma_,u));
> mu_:=_gamma+Mean(gamma_);
> var_:=Variance(gamma_);
> skew_:=simplify(convert(Skewness(gamma_),GAMMA),symbolic);
> kurt_:=simplify(convert(Kurtosis(gamma_),GAMMA),symbolic);
> sol:=subs(m='mu',v='var',solve({mu_=m,var_=v},{k,lambda}));
> #qdf:=_gamma+Quantile(gamma_,p);
> #qdf2:=solve(cdf=p,x);
> pdfgr:=map(_u->simplify(convert(_u,hypergeom),symbolic),[diff(pdf,
> k)/pdf, diff(pdf, lambda)/pdf, diff(pdf, _gamma)/pdf]);
> cdfgr:=map(_u->simplify(convert(_u,hypergeom),symbolic),[diff(cdf, k),
> diff(cdf, lambda), diff(cdf, _gamma)]);
> #dCDFdk:=collect(map(_u->simplify(convert(_u,hypergeom),symbolic),conv
> ert(diff(subs(_gamma=0,cdf2), k),hypergeometric)),x);
> #dCDFdlambda:=map(_u->factor(simplify(convert(_u,hypergeom),symbolic))
> ,diff(cdf2, lambda));
> #dCDFdgamma:=map(_u->simplify(convert(_u,hypergeom),symbolic),diff(cdf
> 2, _gamma));
> collect(expand(simplify(factor(convert(subs(_gamma=0,lambda=1,diff(cdf
> 2,k)),'StandardFunctions'))),trig),k);
> valnum:=k=1.5,lambda=2.5,_gamma=-0.5;
> evalf(subs(valnum,x=1,ddf));
> evalf(subs(valnum,x=1,pdf));
> evalf(subs(valnum,x=1,cdf));
> evalf(subs(valnum,x=1,cf));
> evalf(subs(valnum,x=1,map(_x->_x*pdf,pdfgr)));
> evalf(subs(valnum,x=1,cdfgr));
> evalf(fsolve(subs(valnum,cdf)=0.95,x));
> evalf(subs(valnum,mu_));
> evalf(subs(valnum,sqrt(var_)));
> evalf(subs(valnum,skew_));
> evalf(subs(valnum,kurt_));
> evalf(subs(valnum,var_));
> evalf(subs(valnum,[mu_,sqrt(var_)]));
> evalf(subs(sol,mu=mu_,var=var_,valnum,[k,lambda]));

                              (k - 1)
  pdf := ((x - _gamma) lambda)        exp(-(x - _gamma) lambda)

        lambda/GAMMA(k)


  cdf2 := (GAMMA(k + 2) - GAMMA(k + 1, (x - _gamma) lambda)

         - GAMMA(k + 1, (x - _gamma) lambda) k

                                           k             k
         + exp(-(x - _gamma) lambda) lambda  (x - _gamma)

                                             k             k
         + k exp(-(x - _gamma) lambda) lambda  (x - _gamma) )/

        GAMMA(k + 2)


                                     /     x I  \(-k)
                cf := exp(-I _gamma) |1 - ------|
                                     \    lambda/


                                          k
                        mu_ := _gamma + ------
                                        lambda


                                      k
                           var_ := -------
                                         2
                                   lambda


                                      2
                            skew_ := ----
                                      1/2
                                     k


                                   3 (k + 2)
                          kurt_ := ---------
                                       k


                                                          2
                          -_gamma + mu      (-_gamma + mu)
         sol := {lambda = ------------, k = ---------------}
                              var                 var


  pdfgr := [ln(x - _gamma) + ln(lambda) - Psi(k),

        k - lambda x + lambda _gamma
        ----------------------------,
                   lambda

          k - 1 - lambda x + lambda _gamma
        - --------------------------------]
                     x - _gamma


                   (k + 2)             (k + 1)
  cdfgr := [(lambda        (x - _gamma)

        hypergeom([k + 2, k + 2], [k + 3, k + 3], %1) _gamma -

              (k + 2)             (k + 1)
        lambda        (x - _gamma)

        hypergeom([k + 2, k + 2], [k + 3, k + 3], %1) x

         - 4 Psi(k + 2) GAMMA(k + 2)

                             k             k
         + 4 k exp(%1) lambda  (x - _gamma)

                                      k             k
         - 8 exp(%1) Psi(k + 2) lambda  (x - _gamma)  k

                                    k             k  3
         - exp(%1) Psi(k + 2) lambda  (x - _gamma)  k

                                      k             k  2
         - 5 exp(%1) Psi(k + 2) lambda  (x - _gamma)  k

                           k             k                 2
         + 5 exp(%1) lambda  (x - _gamma)  ln(x - _gamma) k

                           k             k
         + 8 exp(%1) lambda  (x - _gamma)  ln(x - _gamma) k

                         k                        k  3
         + exp(%1) lambda  ln(lambda) (x - _gamma)  k

                         k             k                 3
         + exp(%1) lambda  (x - _gamma)  ln(x - _gamma) k

                           k                        k  2
         + 5 exp(%1) lambda  ln(lambda) (x - _gamma)  k

                           k                        k
         + 8 exp(%1) lambda  ln(lambda) (x - _gamma)  k

                           k             k                  3
         + 4 exp(%1) lambda  (x - _gamma)  + %2 Psi(k + 2) k

                            2                                      3
         + 5 %2 Psi(k + 2) k  + 8 %2 Psi(k + 2) k - %2 ln(lambda) k

                            2
         - 5 %2 ln(lambda) k  - 8 %2 ln(lambda) k

                              3                        2
         - %2 ln(x - _gamma) k  - 5 %2 ln(x - _gamma) k

                                                            2
         - 8 %2 ln(x - _gamma) k - Psi(k + 2) GAMMA(k + 2) k

         - 4 Psi(k + 2) GAMMA(k + 2) k

                                        2
         + ln(x - _gamma) GAMMA(k + 2) k

         + 4 ln(x - _gamma) GAMMA(k + 2) k

                                    2
         + ln(lambda) GAMMA(k + 2) k  + 4 ln(lambda) GAMMA(k + 2) k

                           k                        k
         + 4 exp(%1) lambda  ln(lambda) (x - _gamma)

                                      k             k
         - 4 exp(%1) Psi(k + 2) lambda  (x - _gamma)

                           k             k
         + 4 exp(%1) lambda  (x - _gamma)  ln(x - _gamma)

                         k             k  2
         + exp(%1) lambda  (x - _gamma)  k

         + 4 ln(lambda) GAMMA(k + 2) + 4 ln(x - _gamma) GAMMA(k + 2)

         + 4 %2 Psi(k + 2) - 4 %2 ln(x - _gamma) - 4 %2 ln(lambda))

           /         2                        (k + 1)             k
          /  ((k + 2)  GAMMA(k + 2)), (-lambda        (x - _gamma)  x
         /

                 (k + 1)             k
         - lambda        (x - _gamma)  k x

                 (k + 1)             k
         + lambda        (x - _gamma)  _gamma

                 (k + 1)             k
         + lambda        (x - _gamma)  k _gamma

                 (k + 1)             (k + 1)
         + lambda        (x - _gamma)        k

                 (k + 1)             (k + 1)
         + lambda        (x - _gamma)

                 k             k           k             k  2
         + lambda  (x - _gamma)  k + lambda  (x - _gamma)  k )

        exp(%1)/(GAMMA(k + 2) lambda), - exp(%1) (

               (k + 1)             k
        -lambda        (x - _gamma)  x

                 (k + 1)             k
         - lambda        (x - _gamma)  k x

                 (k + 1)             k
         + lambda        (x - _gamma)  _gamma

                 (k + 1)             k
         + lambda        (x - _gamma)  k _gamma

                 (k + 1)             (k + 1)
         + lambda        (x - _gamma)        k

                 (k + 1)             (k + 1)
         + lambda        (x - _gamma)

                 k             k           k             k  2
         + lambda  (x - _gamma)  k + lambda  (x - _gamma)  k )/(

        (x - _gamma) GAMMA(k + 2))]

  %1 := -(x - _gamma) lambda

  %2 := GAMMA(k + 1, (x - _gamma) lambda)


       2          k        2 GAMMA(k + 1, x)
  - -------- - -------- + -------------------
           2          2          2
    (k + 1)    (k + 1)    (k + 1)  k GAMMA(k)

                         k                          k
                      2 x                          x
         - -------------------------- - ------------------------
                  2                            2
           (k + 1)  k GAMMA(k) exp(x)   (k + 1)  GAMMA(k) exp(x)

           k GAMMA(k + 1, x) ln(x)   2 GAMMA(k + 1, x) ln(x)
         - ----------------------- - -----------------------
                     2                         2
              (k + 1)  GAMMA(k)         (k + 1)  GAMMA(k)

           GAMMA(k + 1, x) Psi(k)   2 GAMMA(k + 1, x) Psi(k)
         + ---------------------- + ------------------------
                   2                          2
            (k + 1)  k GAMMA(k)        (k + 1)  GAMMA(k)

           GAMMA(k + 1, x) ln(x)   k GAMMA(k + 1, x) Psi(k)
         - --------------------- + ------------------------
                   2                         2
            (k + 1)  k GAMMA(k)       (k + 1)  GAMMA(k)

                        k
                       x                     1         ln(x)
         - --------------------------- - ---------- + --------
                  2  2                          2            2
           (k + 1)  k  GAMMA(k) exp(x)   (k + 1)  k   (k + 1)

            2
           k  Psi(k)    GAMMA(k + 1, x)      GAMMA(k + 1, x)
         - --------- + ----------------- + --------------------
                  2           2                   2  2
           (k + 1)     (k + 1)  GAMMA(k)   (k + 1)  k  GAMMA(k)

                                    2
            Psi(k)    2 k Psi(k)   k  ln(x)   2 k ln(x)
         - -------- - ---------- + -------- + ---------
                  2           2           2          2
           (k + 1)     (k + 1)     (k + 1)    (k + 1)

                     k                          k
                  k x  ln(x)                   x  ln(x)
         + ------------------------ + --------------------------
                  2                          2
           (k + 1)  GAMMA(k) exp(x)   (k + 1)  k GAMMA(k) exp(x)

                     k                         k
                  2 x  ln(x)                2 x  Psi(k)
         + ------------------------ - ------------------------
                  2                          2
           (k + 1)  GAMMA(k) exp(x)   (k + 1)  GAMMA(k) exp(x)

            k
           x  x hypergeom([k + 1, k + 1], [k + 2, k + 2], -x)
         - --------------------------------------------------
                                 2
                          (k + 1)  k GAMMA(k)

                    k                          k
                 k x  Psi(k)                  x  Psi(k)
         - ------------------------ - --------------------------
                  2                          2
           (k + 1)  GAMMA(k) exp(x)   (k + 1)  k GAMMA(k) exp(x)


            valnum := k = 1.5, lambda = 2.5, _gamma = -0.5


                                 ddf


                             0.1284713816


                             0.9424415478


                    0.4289502207 + 0.7851195123 I


             [0.1651198816, -0.1156242435, 0.2783546603]


            [-0.08756249102, 0.07708282900, -0.1284713816]


                             1.062945580


                             0.1000000000


                             0.4898979484


                             1.632993162


                             6.999999999


                             0.2400000000


                     [0.1000000000, 0.4898979484]


                              [1.5, 2.5]

> restart:assume(k,integer,k>2):
> eq:=F(k+1)=F(k)-x^k*exp(-x)/k/GAMMA(k);
> collect(expand(solve(eq,F(k+1))),F(k));

                                           k~
                                          x   exp(-x)
                eq := F(k~ + 1) = F(k~) - ------------
                                          k~ GAMMA(k~)


                                      k~
                                     x
                     F(k~) - -------------------
                             k~ GAMMA(k~) exp(x)

> map(factor,collect(expand(solve(subs(k=k-1,eq),F(k-1))),F(k)));

                                      k~
                                     x
                      F(k~) + ------------------
                              GAMMA(k~) x exp(x)

> int(log(x),x);

                             x ln(x) - x

> 

