polynomialDegree

Degree of a polynomial expression.

Category: Mathematics > Polynomials

Syntax

d = polynomialDegree(p)

Total degree of p in all its symbolic variables.

d = polynomialDegree(p, vars)

Degree with respect to the variables vars.

Description

With a vector of variables, the degree is the largest total degree of a term in those variables, so x^2*y^3 has degree 5 in [x y]. Terms free of the chosen variables count as constants for the degree, which is why x*y + y^4 has degree 4 in y and polynomialDegree(x^2, y) is 0.

An expression that is not a polynomial in the chosen variables, such as sin(x) or 1/x, is an error.

Input arguments

p
Symbolic polynomial expression.
vars
Variable or vector of variables.

Output arguments

d
Nonnegative integer degree. A constant has degree 0.

Example

One and several variables

syms x y
polynomialDegree(x^3 + x)
polynomialDegree(x^2*y + y, x)
polynomialDegree(x^2*y^3, [x y])
Output
ans = 3
ans = 2
ans = 5

See also

coeffs sym2poly poly2sym degree