Coefficients of polynomial

`___ = coeffs(___,'All')`

returns
all coefficients, including coefficients that are 0. For example, `coeffs(2*x^2,'All')`

returns ```
[
2, 0, 0]
```

instead of `2`

.

Find the coefficients of this univariate polynomial.

syms x c = coeffs(16*x^2 + 19*x + 11)

c = [ 11, 19, 16]

Find the coefficients of this polynomial with
respect to variable `x`

and variable `y`

.

syms x y cx = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, x) cy = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, y)

cx = [ 4*y^3, 3*y^2, 2*y, 1] cy = [ x^3, 2*x^2, 3*x, 4]

Find the coefficients of this polynomial with
respect to both variables `x`

and `y`

.

syms x y cxy = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [x,y]) cyx = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [y,x])

cxy = [ 4, 3, 2, 1] cyx = [ 1, 2, 3, 4]

Find the coefficients and the corresponding terms of this univariate polynomial.

syms x [c,t] = coeffs(16*x^2 + 19*x + 11)

c = [ 16, 19, 11] t = [ x^2, x, 1]

Find the coefficients and the corresponding
terms of this polynomial with respect to variable `x`

and
variable `y`

.

syms x y [cx,tx] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, x) [cy,ty] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, y)

cx = [ 1, 2*y, 3*y^2, 4*y^3] tx = [ x^3, x^2, x, 1] cy = [ 4, 3*x, 2*x^2, x^3] ty = [ y^3, y^2, y, 1]

Find the coefficients of this polynomial with respect to both
variables `x`

and `y`

.

syms x y [cxy, txy] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [x,y]) [cyx, tyx] = coeffs(x^3 + 2*x^2*y + 3*x*y^2 + 4*y^3, [y,x])

cxy = [ 1, 2, 3, 4] txy = [ x^3, x^2*y, x*y^2, y^3] cyx = [ 4, 3, 2, 1] tyx = [ y^3, x*y^2, x^2*y, x^3]

Find all coefficients of a polynomial, including
coefficients that are `0`

, by specifying the option `'All'`

.

Find all coefficients of 3*x*^{2}.

syms x c = coeffs(3*x^2, 'All')

c = [ 3, 0, 0]

If you find coefficients with respect to multiple variables
and specify `'All'`

, then `coeffs`

returns
coefficients for all combinations of the variables.

Find all coefficients and corresponding terms of *a**x*^{2} + *b**y*.

syms a b y [cxy, txy] = coeffs(a*x^2 + b*y, [y x], 'All')

cxy = [ 0, 0, b] [ a, 0, 0] txy = [ x^2*y, x*y, y] [ x^2, x, 1]

Was this topic helpful?