ratchristof SciMax Toolbox ratdenom

SciMax Toolbox >> ratcoef

ratcoef

Maxima Function

Calling Sequence

ratcoef (expr, x, n)
ratcoef(expr,x)

Description

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
ratchristof SciMax Toolbox ratdenom