polynomialDegree

Degree of polynomial

Description

example

polynomialDegree(p) returns the degree of polynomial p with respect to all variables found in p by symvar.

example

polynomialDegree(p,vars) returns the degree of p with respect to the variables in vars.

Examples

collapse all

Find the degree of the polynomial x^3 + x + 1.

syms x
p = x^3 + x + 1;
deg = polynomialDegree(p)
deg =
3

Specify variables as the second argument of polynomialDegree. Find the degree of the polynomial a^2*x^3 + b^6*x with the default independent variables found by symvar, the variable x, and the variables [a x].

When using the default variables, the degree is 7 because, by default, a and b are variables. So the total degree of b^6*x is 7.

syms a b x
p = a^2*x^3 + b^6*x;
deg = polynomialDegree(p)    % uses symvar
deg =
7
deg = polynomialDegree(p,x)
deg =
3
vars = [a x];
deg = polynomialDegree(p,vars)
deg =
5

Input Arguments

collapse all

Polynomial, specified as a symbolic expression or function.

Polynomial variables, specified as a vector of symbolic variables.