coeffs

Coefficients of polynomial

Syntax

Description

example

C = coeffs(p) returns coefficients of the polynomial p with respect to all variables determined in p by symvar.

example

C = coeffs(p,var) returns coefficients of the polynomial p with respect to the variable var.

example

C = coeffs(p,vars) returns coefficients of the multivariate polynomial p with respect to the variables vars.

example

[C,T] = coeffs(___) returns the coefficient C and the corresponding terms T of the polynomial p.

Examples

Coefficients of a Univariate Polynomial

Find the coefficients of this univariate polynomial:

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

Coefficients of a Multivariate Polynomial with Respect to a Particular Variable

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]

Coefficients of a Multivariate Polynomial with Respect to Two Variables

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]

Coefficients and Corresponding Terms of a Univariate Polynomial

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]

Coefficients and Corresponding Terms of a Multivariate Polynomial

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]

Input Arguments

expand all

p — Polynomialsymbolic expression | symbolic function

Polynomial, specified as a symbolic expression or function.

var — Polynomial variablesymbolic variable

Polynomial variable, specified as a symbolic variable.

vars — Polynomial variablesvector of symbolic variables

Polynomial variables, specified as a vector of symbolic variables.

Output Arguments

expand all

C — Coefficients of polynomialsymbolic vector | symbolic number | symbolic expression

Coefficients of polynomial, returned as a vector of symbolic numbers and expressions. If there is only one coefficient and one corresponding term, then C is returned as a scalar.

T — Terms of polynomialsymbolic vector | symbolic expression | symbolic number

Terms of polynomial, returned as a vector of symbolic expressions and numbers. If there is only one coefficient and one corresponding term, then T is returned as a scalar.

See Also

|

Was this topic helpful?