COEFF INDEX

COEFF _ _ _ _ _ _ _ _ _ _ _ _ operator

The coeff operator returns the coefficients of the powers of the specified variable in the given expression, in a list.

syntax:

coeff(<expression>,<variable>)

<expression> is expected to be a polynomial expression, not a rational expression. Rational expressions are accepted when the switch ratarg is on. <variable> must be a kernel. The r esults are returned in a list.

examples:


coeff((x+y)**3,x); 

    3     2
  {Y  ,3*Y  ,3*Y,1} 


coeff((x+2)**4 + sin(x),x); 

  {SIN(X) + 16,32,24,8,1} 


high_pow; 

  4 


low_pow; 

  0 


ab := x**9 + sin(x)*x**7 + sqrt(y); 
 


                          7     9
  AB := SQRT(Y) + SIN(X)*X   + X


coeff(ab,x); 

  {SQRT(Y),0,0,0,0,0,0,SIN(X),0,1}

The variables high_pow and low_pow are set to the highest and lowest powers of the variable, respectively, appearing in the expression.

The coefficients are put into a list, with the coefficient of the lowest (constant) term first. You can use the usual list access methods (first, second, third, rest, length , and part) to extract them. If a power does not appear in the expression, the corresponding element of the list is zero. Terms involving functions of the specified variable but not including powers of it (for example in the expression x**4 + 3*x**2 + tan(x)) are placed in the constant term.

Since the coeff command deals with the expanded form of the expression, you may get unexpected results when exp is off, or when factor or ifactor are on.

If you want only a specific coefficient rather than all of them, use the coeffn operator.