Confused with the concept of degrees in polynomials

Let's say I have a function $ f(x) = (x + 1)^2 (2x^2 + 5) (x + 4)$ , and this function can also be $ f(x) = 2x^5 + 12x^4 + 23x^3 + 38x^2 + 45x + 20,$ would the degree of the function be $2$ or $5$? Which highest exponent should I choose when finding the degree of a polynomial?


Good question.

To decide the degree of the polynomial you need to fully expand it out. So if I wanted to know the degree of the polynomial $f(x)=(x+1)(x-1)$ you need to expand the parentheses and write it as $f(x)=x^2-1$ to declare its degree is $2$. There is actually a shorter way of doing this though. If you have the polynomial written as some product of other polynomials, e.g $f(x)=(x^2+x+1)(x+1)$ then the degree of $f$ is the sum of the highest degrees in each of its factors, i.e $\operatorname{deg}f=2+1=3$. In general, if you have a polynomial say $$P(x)=\prod_{i=1}^n p_i(x)^{r_i}$$ Then $$\operatorname{deg}P=\sum_{i=1}^n r_i\cdot \operatorname{deg}p_i$$