8.30 coeff (6.10.97)

8.30.1 David C Royster
8.30.2 Lewis McCarthy (8.10.97)
8.30.3 Douglas B. Meade (8.10.97)
8.30.4 Harald Boeing (9.10.97)
8.30.5 Keith O. Geddes (24.10.97)

8.30.1 David C Royster

What is happening in the following example? I have gotten the correct answer in a fresh worksheet but only after some prior checking. All other times I have had the following:

> f := (x^2-1)*x; 
> coeff(f,x,1); 
 
0 
 
> coeff(expand(f),x,1); 
 
-1
 

Is this the way that I should be expecting it to work?

The bug is removed with Maple V Release 5, U. Klein

8.30.2 Lewis McCarthy (8.10.97)

coeff() works syntactically, and not necessarily semantically. In a case like this you get finer-grained control over the amount of work done by a function call. However, something more powerful is not always easier to use....

8.30.3 Douglas B. Meade (8.10.97)

Yes. The first item in the online help for coeff states:

   The coeff function extracts the coefficient of x^n in the 
   polynomial p. Note that input expression p must be collected 
   in x. Use the function collect(p,x) prior to calling coeff, 
   if necessary.

The point is that coeff does NOT automatically expand the first argument. (This makes sense when you think about the effort that would be wasted to explicitly expand this argument on every call - particularly when the argument is huge and involves symbolic parameters.)

You might be interested in the coeffs command and other commands that are cross-listed at the bottom of the online help for coeff.

8.30.4 Harald Boeing (9.10.97)

I guess you are using Maple V Release 4. Because if you took Release 3 you’d get the ERROR-message

Error, unable to compute coeff.

The builtin help function explains this behaviour: For Release 3 AND 4 it is claimed, that the input polynomial HAS to be collected in x, if you want to calculate any coefficient of x.

That’s why the call to expand prior to coeff solves the problem. However, despite the help text for coeff in Release 4, another help text refering to the updates (to see it, type "?updatesR4,language") claims that

         "coeff(a,x,i); where a is a polynomial in x works without 
         the need of using collect." !!!

It’s true for their example there. From my testing I’d say it only works if the input polynomial is an already collected polynomial raised to nonnegative integer power.

8.30.5 Keith O. Geddes (24.10.97)

| From: Harald Boeing <boeing@zib.de> 
| 
|   "coeff(a,x,i); where a is a polynomial in x works without ...

Right, there was a remaining bug in Release 4. It is working correctly in the development version (i.e. for future releases) without requiring collect to be used prior to coeff.

For the future, coeff does automatically collect.