number of variables in a multivariable polynomal ?



If you have to ratdisrep then rat again, I don't see the advantage of using
the internal structure of CREs for this calculation -- anyway, if an end
user is calling a ?xxx function, I think this is an indication that we
haven't provided proper abstractions at the Maxima level.

You might think that the advantage is in cases like exp(x)+exp(2*x), where
rat knows that this is a polynomial in exp(x); but alas it treats
exp(x/2)+exp(x) as a polynomial in exp(x) and exp(x/2). I don't know any
simple workaround for this (though radcan knows about this algebraic
dependence, it returns a general-representation result).

I suppose you can use rat form to ensure that there *aren't* any
non-algebraic kernels in the expression. But in the simple case where you
know in advance that you have a polynomial, listofvars seems appropriate.

             -s

On Dec 15, 2007 11:04 AM, Richard Fateman <fateman at cs.berkeley.edu> wrote:

> There is a list of all the variables in an expression in the header of an
> expression in rat form.
> That list might include, in some cases, variables that have been cancelled
> out, e.g. rat(x*(y+1)/(xy+y)) will have x and y in it, even though it is
> 1.
> rat(ratdisrep(rat(..))   will fix it, I think.
>
> If e is the rat expression,
> ?length(?third(?first( e))      says how many vars in e.
>
> Someone may have written a program to do this by much clumsier methods and
> put it in some library.
> RJF
>
>
>
> > -----Original Message-----
> > From: maxima-bounces at math.utexas.edu
> > [mailto:maxima-bounces at math.utexas.edu] On Behalf Of S. Newhouse
> > Sent: Saturday, December 15, 2007 4:52 AM
> > To: maxima at math.utexas.edu
> > Subject: number of variables in a multivariable polynomal ?
> >
> > 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
> >
> > TIA,
> >  -sen
> >
> >
> >
> >
> >
> > _______________________________________________
> > Maxima mailing list
> > Maxima at math.utexas.edu
> > http://www.math.utexas.edu/mailman/listinfo/maxima
> >
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>