# [Maxima] hgfred and create-poly

Dieter Kaiser drdieterkaiser at web.de
Fri Jan 29 11:58:51 CST 2010

```If we have a negative integer (a number) in the first argument list of
\$hgfred, e.g. hgfred([-1,b],[c],x), the function create-poly is called
to return the appropriate polynomial.

Because we have an integer number, we can always expect a simple
polynomial.

Here are some simple examples:

(%i12) hgfred([-1,b],[],x);
(%o12) -b*(1-1/(b*x))*x

(%i13) hgfred([-1,b1,b2],[],x);
(%o13) 1-b1*b2*x

(%i14) hgfred([-1,b1,b2],[c1],x);
(%o14) 1-b1*b2*x/c1

(%i15) hgfred([-1,b1,b2],[c1,c2],x);
(%o15) 1-b1*b2*x/(c1*c2)

We get some problems with the function create-poly, because I think
create-poly  tries to be too smart. It does several checks which are
only of interest if we have a symbolic negative integer. But create-poly
is never called for symbolic integers.

That is what we get for 2F1(-1,b; c; x). For this case create-poly calls
2f1polys to simplify the hypgergeometric function. For symbolic
parameters we get an unnecessary question. The reason is that we call
the routine lagpol, which tries to look if b is an integer too.

(%i16) hgfred([-1,b],[c],x);
Is b an integer?

n;
(%o16) 1-b*x/c

Because of some additional checks in 2f1polys we can get results in
terms of unsimplified polynomials:

(%i18) hgfred([-1,1],[1/2],x);
(%o18) chebyshev_t(1,1-2*x)
(%i19) ev(%),nouns;
(%o19) 1-2*x

(%i20) hgfred([-1,3],[3/2],x);
(%o20) ultraspherical(1,1,1-2*x)/2
(%i21) ev(%),nouns;
(%o21) 1-2*x

Especially, when we have a number as an argument I think it is of
interest to get the most simple result immediately. Now we have to do an
extra evaluation:

(%i7) hgfred([-1,3],[3/2],1);
(%o7) ultraspherical(1,1,-1)/2
(%i8) ev(%),nouns;
(%o8) -1

On the other hand we have no code to handle a symbolic negative integer
in a lot of cases:

(%i1) declare(n,integer)\$
(%i2) assume(n>0)\$

(%i3) hgfred([-n,b],[c],x);
(%o3) %f[2,1]([-n,b],[c],x)

I would like to suggest the following:

1. For a negative integer (a number) expand the polynomials immediately.
The code of create-poly can be simplified a lot for this case.
2. Improve create-poly to handle negative symbolic integers and
try to return the most special polynomial.
3. Perhaps we can add the functionality to orthopoly to suppress the
automatic expansion of polynomials.

The last point is of special interest when we introduce more code for
symbolic integers. Now we have the following:

(%i1) declare(n,integer)\$

(%i2) jacobi_p(n,a,b,x);
(%o2) pochhammer(a+1,n)*('sum(pochhammer(-n,i1)*pochhammer(n+b+a+1,i1)
*(1-x)^i1
/(pochhammer(a+1,i1)*2^i1*i1!),i1,0,n))
/n!

For this case it might be preferable to have the possibility to get an
unsimplified expression.

Dieter Kaiser

```