How to find number of variables in a monomial in Maple?

123 Views Asked by At

Given a monomial $m$. How to find number of variables in $m$ in Maple? For example, let $m=2*x*x$. Then the output to be $2$ (two same variable $x$ in $m$). Let $m=-2*x*y*y$. The output is $3$ (variables are $x, x, y$). How could we do this in Maple? Thank you very much.

2

There are 2 best solutions below

0
On BEST ANSWER

degree() will work. Documentation.

0
On

How about this? - if the monomial is m then

for v in indets(m) do m:=subs(v=_newvar,m): od:
ans:=diff(m,_newvar)*_newvar/m;