The result of hgfred([-n,1+n],[1],x) is not correct. This is what Maxima gives:

(%i1) res:hgfred([-n,n+1],[1],x);

Is x positive, negative, or zero?

p;

Is x-1 positive, negative, or zero?

n;

(%o1) legendre_p(-n-1,1-2*x)

The correct result is legendre_p(n, 1-2*x). For the special values n=1, n=2, n=3, ... Maxima gives the correct results:

(%i2) hgfred([-1,1+1],[1],x);

(%o2) 1-2*x

(%i3) hgfred([-2,2+1],[1],x);

(%o3) 6*x^2-6*x+1

(%i4) hgfred([-3,3+1],[1],x);

(%o4) -20*x^3+30*x^2-12*x+1

We can not reproduce the correct results, when we insert the special values in the result from above:

(%i5) res,n=1;

(%o5) 0

(%i6) res,n=2;

(%o6) 0

(%i7) res,n=3;

(%o7) 0

Furthermore, I think the question for the sign of the argument x is not necessary. The problem is in the algorithm of the routine legf14.

Dieter Kaiser