Re: PolynomialQ ?
- To: mathgroup at smc.vnet.net
- Subject: [mg34894] Re: [mg34866] PolynomialQ ?
- From: Sseziwa Mukasa <mukasa at jeol.com>
- Date: Wed, 12 Jun 2002 02:15:22 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On Tuesday, June 11, 2002, at 05:00 AM, Juan wrote: > Hi,I tried to check is a polynomial have a variable, ussing the function > PolynomialQ. > > In[1]:=p = x^3 - 2*x^2 + x - 1; > In[2]:=PolynomialQ[p, x] > Out[2]=True > In[3]:=PolynomialQ[p, y] > Out[3]=True > In[4]:=PolynomialQ[p, z^2] > Out[4]=True > In[5]:=PolynomialQ[p, {u, v}] > Out[5]=True > > What is the thing I am doing wrong? > > Nothing, p is a polynomial in all the variables you tried since it could always be the constant term in a zero degree polynomial. If you want to know if an expression is a nonconstant polynomial in a variable, first check if the expression contains your variable, then check if it's a polynomial: If[FreeQ[expr,var],False,PolynomialQ[expr,var]]. You could also check if your variable is one of the independent variables of the polynomial: PolynomialQ[expr,var] && MemberQ[Variables[expr],var]. Regards, Ssezi