number of variables in a multivariable polynomal ?
Subject: number of variables in a multivariable polynomal ?
From: Barton Willis
Date: Sat, 15 Dec 2007 07:51:10 -0600
-----maxima-bounces at math.utexas.edu wrote: -----
>Hello,
> Is there a function in maxima which will extract the number of
>variables in a user defined polynomial of several variables?
>
>E.g. let's call such a function 'num_vars'.
>
> It should have the property that if
> p= -2*x[1]^3*x[5]^4 + x[1]*x[6]
> then
> num_vars(p)=6
I see 3 variables in p, not 6. The variables are x[1], x[5], and x[6]. So I
don't
understand why you say it has 6. The largest subscript on x is 6 -- is
that what you want? If not,
(%i1) num_vars(x) := block([listconstvars : false], length(listofvars(x)))$
(%i2) num_vars(-2*x[1]^3*x[5]^4 + x[1]*x[6]);
(%o2) 3
Barton