Work on $hgfred



I have done some work on the algorithm of $hgfred and I have started
with the hypergeometric functions 0F1 and 1F1. The aim is to get more
complete and more simple results.

These are some old and new results for the 0F1 function:

hgfred simplifies wrongly:

(%i13) hgfred([],[b],0);
(%o13) 0

This is a new result:

(%i10) hgfred([],[b],0);
(%o10) 1

On point is that at a lot of places $hgfred does not use simplifying
code. One example:

(%i1) assume(x>0);

We wish to expand the result, but it does not work:

(%i2) hgfred([],[1/2],x),besselexpand:true;
(%o2) sqrt(%pi)*bessel_i(-1/2,2*sqrt(x))*x^(1/4)
(%i3) hgfred([],[1/2],-x),besselexpand:true;
(%o3) sqrt(%pi)*bessel_j(-1/2,2*sqrt(x))*x^(1/4)

We can improve the code to get the expected simplified results:

(%i8) hgfred([],[1/2],x),besselexpand:true;
(%o8) cosh(2 sqrt(x))
(%i9) hgfred([],[1/2],-x),besselexpand:true;
(%o9) cos(2 sqrt(x))

Now some work on the 1F1 function.

We get results in terms of the %gammagreek function:

(%i14) hgfred([a],[a+1],z);
(%o14) a*%gammagreek(a,-z)/(-z)^a

This new example uses a flag prefer_gamma_incomplete to get the results
in terms of the Incomplete Gamma function. This might be preferable,
because we have more support for the Incomplete Gamma function:

(%i16) hgfred([a],[a+1],z),prefer_gamma_incomplete:true;
(%o16) -(a*gamma_incomplete(a,-z)-a*gamma(a))/(-z)^a

We can use in addition the flag gamma_expand to reduce expressions which
contain Gamma functions which differ by an integer in the argument a:

(%i16) hgfred([a],[a+2],x), 
       prefer_gamma_incomplete:true, gamma_expand:true;
(%o16) -((a^2+a)*(-x)^a*%e^x+((a^2+a)*gamma_incomplete(a,-x)
                             +(-a^2-a)*gamma(a))
                             *x+(a^3+a^2)*gamma_incomplete(a,-x)
                            +(-a^3-a^2)*gamma(a))/((-x)^a*x)

Polynomials and Gamma functions are not simplified:

(%i14) hgfred([-2],[b],z);
(%o14) 2*gen_laguerre(2,b-1,z)*gamma(b)/gamma(b+2)

Maxima can simplify both. For this case the expansion of the Gamma
functions is done automatically:

(%i17) hgfred([-2],[b],z);
(%o17) z^2/(b*(b+1))-2*z/b+1

Some results are very bad simplified:

(%i15) hgfred([-11/2],[-9/2],x);
(%o15) -4*x^(11/2)
         *(6*sqrt(x)
            *(sqrt(%pi)*%i*erf(%i*sqrt(x))*x^(11/2)*%e^-x/2
             -77*sqrt(%pi)*%i*erf(%i*sqrt(x))*x^(9/2)*%e^-x/4
             +2079*sqrt(%pi)*%i*erf(%i*sqrt(x))*x^(7/2)*%e^-x/8
             -24255*sqrt(%pi)*%i*erf(%i*sqrt(x))*x^(5/2)*%e^-x/16
             +121275*sqrt(%pi)*%i*erf(%i*sqrt(x))*x^(3/2)*%e^-x/32
             -218295*sqrt(%pi)*%i*erf(%i*sqrt(x))*sqrt(x)*%e^-x/64
             +72765*sqrt(%pi)*%i*erf(%i*sqrt(x))*%e^-x/(128*sqrt(x))
             +10395*sqrt(%pi)*%i*erf(%i*sqrt(x))*%
e^-x/(256*x^(3/2))+x^5/2
             -19*x^4+2005*x^3/8-2799*x^2/2+102207*x/32
+10395/(128*x)-36435/16)
            *%e^x
          +15*(sqrt(%pi)*%i*erf(%i*sqrt(x))*x^(11/2)*%e^-x/2
          ... and a lot of more terms

We can improve this and get:

(%i18) hgfred([-11/2],[-9/2],x);
(%o18) (sqrt(x)*(32*x^5+16*x^4+24*x^3+60*x^2+210*x+945)*%e^x
        +32*sqrt(%pi)*%i*erf(%i*sqrt(x))*x^6)
        /(945*sqrt(x))

The following results Maxima can not calculate. We have to add an
algorithm for functions of the form 1F1([n+1/2],[m],z), where n is an
integer and m is a positive integer. The new results are in terms of the
Bessel I function:

(%i25) hgfred([-3/2],[1],x);
(%o25) ((bessel_i(2,x/2)-4*bessel_i(1,x/2)+3*bessel_i(0,x/2))*x^2
        +(12*bessel_i(1,x/2)-12*bessel_i(0,x/2))*x+6*bessel_i(0,x/2))
        *%e^(x/2)/6

Furthermore, we can introduce a more general algorithm for functions
like 1F1([a],[2*a+n],z), where a is not an integer, and n is an integer.
Again the results are in terms of the Bessel I function:

(%i58) hgfred([1/3],[2/3+1],x);
(%o58) -3*2^(2/3)*gamma(5/6)*(bessel_i(5/6,x/2)/6-bessel_i(-1/6,x/2)/6)
         *x^(1/6)*%e^(x/2)

(%i59) hgfred([1/5],[2/5+2],x);
(%o59) -5*2^(2/5)*gamma(7/10)
         *(-bessel_i(17/10,x/2)/20+7*bessel_i(7/10,x/2)/20
                                  -3*bessel_i(-3/10,x/2)/10)*x^(3/10)
         *%e^(x/2)/3


There is one topic to discuss:

To get the following simple result Maxima has to simplify polynomials
immediately.

(%i17) hgfred([-2],[b],z);
(%o17) z^2/(b*(b+1))-2*z/b+1

We no longer get results in terms of the Laguerre or Hermite functions
like the following:

(%i14) hgfred([-2],[b],z);
(%o14) 2*gen_laguerre(2,b-1,z)*gamma(b)/gamma(b+2) 

It is possible to improve the code further to get numerical results in
float or bigfloat precision for the simplified hypergeometric functions.
Furthermore, some more specific cases like 1F1([a],[1],z) or
1F1([a],[0],z) can be added.

Dieter Kaiser