### The Maxima on-line user's manual

Algebra Calculator

#### Ratcoef

Function: ratcoef (<expr>, <x>, <n>)

Function: ratcoef (<expr>, <x>) Returns the coefficient of the expression `<x>^<n>` in the expression <expr>. If omitted, <n> is assumed to be 1.

The return value is free (except possibly in a non-rational sense) of the variables in <x>. If no coefficient of this type exists, 0 is returned.

`ratcoef` expands and rationally simplifies its first argument and thus it may produce answers different from those of `coeff` which is purely syntactic. Thus `ratcoef ((x + 1)/y + x, x)` returns `(y + 1)/y` whereas `coeff` returns 1.

`ratcoef (<expr>, <x>, 0)`, viewing <expr> as a sum, returns a sum of those terms which do not contain <x>. Therefore if <x> occurs to any negative powers, `ratcoef` should not be used.

Since <expr> is rationally simplified before it is examined, coefficients may not appear quite the way they were envisioned.

Example:

```          (%i1) s: a*x + b*x + 5\$
(%i2) ratcoef (s, a + b);
(%o2)                           x```

```(%o1)                                true
(%i2) ```

### Related Examples

##### ratcoef

s: a*x + b*x + 5;

ratcoef (s, a + b);

Calculate

? ratcoef;

Calculate

##### ratcoef

poly:(x-a)*(x-b)*(x-c...

ratcoef(poly,1);

Calculate

##### ratcoef

s: a*x*2 + b*x + 5;

ratcoef (s, a + b);

Calculate

##### ratcoef

s: a*x + b*x*x + 5;

ratcoef (s, a + b);

Calculate

##### ratcoef

eq1:Ncg/(sumNo-sumNwo...

eq2:(Nc-Ncg)/(sumNwo+...

eq3:eq1 / eq2 - Kc = 0;

Calculate

##### ratcoef

s: a*x + b*x + 5;

ratcoef (s, a + b);

Calculate

##### ratcoef-ratsimp

poly:(x-a)*(x-b)*(x-c...

ratsimp(poly);

ratcoef(poly,1);

Calculate

##### ratcoef

s: a*x + b*x*x + 5;

ratcoef (s, a + b);

Calculate

##### ratcoef

s: a*x + b*x*x + 5;

ratcoef (s, a + b);

Calculate