(rat)coeff question / proposal



Martin Rubey points out that ratcoeff(x^k,x,2) => 0, and suggests that
it instead return a noun form.  (Note by the way that ratcoeff(x^k,x,k)
=> 1.)

Another possibility is a conditional, (k=2 => 1; k<>2 => 0) -- though
Maxima currently doesn't support them.  (I am working on a simpleminded
package implementing them, but it will be a long time before they are
widely used in the rest of Maxima.)

I'm not sure, though, that ratcoeff is the function that should be doing
this.  Though Ratcoeff appears to be more 'semantic' than Coeff, it is
really just syntactic in terms of the Rat representation.  Consider:

  ratcoeff(x/(1-x),x,1) => 0

but

  ratcoeff(x/sqrt(x+1),x,1) => 1/sqrt(x+1)

and how about

  qq: x^k + x^(k+1)
  ratcoeff(qq,x,k+1) => 1
  ratcoeff(qq,x,k) => x+1
  ratcoeff(qq,x,k-a) => x^a * (x+1)

Note that the results are not free of x (not even rationally, despite
what the documentation says), and also that
sum(ratcoeff(...,k+i),i,-inf,inf) does not equal the original
expression.

If ratcoeff is to become "a little" semantic, it's not clear where the
line should be.

I suppose you might expect

  ratcoeff( (x+1)^k, x, 3 ) => binomial(k,3)

but do you also expect the closed form for ratcoeff ( (x^a+x^b)^k ,x,3)?
Or how about

  ratcoeff( (1-x^2)*sinh(atanh(x))^2 , x, 2 ) => 1

....  (You can easily get this last one with Taylor, by the way.)