Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Get the total degree of a polynomial in any number of variables
| ResourceFunction["PolynomialTotalDegree"][f,vars] gives the total degree of f in the variables vars. | 
The term of highest degree is x2y with total degree 3:
| In[1]:= | ![ResourceFunction["PolynomialTotalDegree"][(x^2 + x + 1) y, {x, y}]](https://www.wolframcloud.com/obj/resourcesystem/images/bbd/bbd6b838-01b8-49bf-8172-917210b5f7f0/2eec302d1cc4c6e9.png)  | 
| Out[1]= |   | 
Since xSin[x] is not a polynomial, the input here is returned unevaluated:
| In[2]:= | ![ResourceFunction["PolynomialTotalDegree"][x Sin[x], {x, y}]](https://www.wolframcloud.com/obj/resourcesystem/images/bbd/bbd6b838-01b8-49bf-8172-917210b5f7f0/676bea85e4d07ac6.png)  | 
| Out[2]= |   | 
This works, though:
| In[3]:= | ![ResourceFunction["PolynomialTotalDegree"][x Sin[x], {x, Sin[x]}]](https://www.wolframcloud.com/obj/resourcesystem/images/bbd/bbd6b838-01b8-49bf-8172-917210b5f7f0/62bd679042c08bc7.png)  | 
| Out[3]= |   | 
This work is licensed under a Creative Commons Attribution 4.0 International License