For example applied to y^2*x^3 + z^2+1
it should give 5
due to the y^2*x^3
component.
2 Answers
$\begingroup$
$\endgroup$
Max[Total@*First /@ CoefficientRules[y^2*x^3 + z^2 + 1]]
5
This extracts rules for all coefficient combinations, ignores the constant multiplier for them, sums powers in each of them, and takes the largest sum.
$\begingroup$
$\endgroup$
2
may be this will work in general. Did not test it fully
ClearAll[x,y,z];
p = y^2* x^3 + z^2 + 1;
Exponent[p /. {y -> x, z -> x}, x]
(* 5 *)
-
1$\begingroup$ You could also automate the replacement of variables with
Exponent[p /. Alternatives @@ Variables@p -> x, x]
. $\endgroup$– kirmaCommented Apr 24, 2020 at 9:28 -