MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MonomialQ

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33557] Re: [mg33542] MonomialQ
  • From: Andrzej Kozlowski <andrzej at bekkoame.ne.jp>
  • Date: Sun, 31 Mar 2002 04:09:05 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Here is another way. It does not use Expand but an undocumented function 
Internal`DistributedTermsList. This kind of code  has the disadvantage 
that it may not work in future versions of Mathematica.

In[1]:=
MonomialQ[f_,l_List]:=
   Module[{u=Internal`DistributedTermsList[f,l]},
     Length[u[[1]]]==1&&Last[u]==l]

In all your cases we the desired answer:

In[2]:=
MonomialQ[(a b)^3/(b c),{a,b}]

Out[2]=
True

In[3]:=
MonomialQ[(a b)^3/(b c),{a,c}]

Out[3]=
False

In[4]:=
MonomialQ[(a b)^3/(b c)-c,{a,b}]

Out[4]=
False

In[5]:=
MonomialQ[(a+b)(a+c),{a}]

Out[5]=
False

In[6]:=
MonomialQ[(a+b)(a+c)-(a^2+b c),{a}]

Out[6]=
True

Andrzej Kozlowski
Toyama International University
JAPAN
http://platon.c.u-tokyo.ac.jp/andrzej/

On Friday, March 29, 2002, at 08:13  PM, Detlef Mueller wrote:

> Hello,
>
> I want to test, wether an expression is a Monomial
> with respect to a List of Variables.
> Here a Monomial is defined as some coefficient
> multiplied by a product of powers of the
> Variables: c*v1^p1*... vn^pn,
> where c must not depend on any of v1,..vn.
> (this is sometimes called "term").
>
> Similar to the build in Function PolynomialQ.
>
> Say
>
> MonomialQ[(a b)^3/(b c),{a,b}] -> True
> MonomialQ[(a b)^3/(b c),{a,c}] -> False
> MonomialQ[(a b)^3/(b c)-c,{a,b}] -> False
> MonomialQ[(a+b)(a+c),{a}] -> False
> MonomialQ[(a+b)(a+c)-(a^2+bc),{a}]->True
>
> My current Implementation is
>
> MonomialQ[a_,L_List] :=
>     PolynomialQ[a, L] &&               (* must be Polynomial and *)
>       Head[Expand[a, x_ /; MemberQ[L, x]]] =!= Plus;
>
> Maybe, there is no better way, but I wonder, if
> the Expand with Pattern is a good Idea here.
>
> Since in most Cases "a" _is_ in fact a Monomial
> in simple power-product-form, and since this is
> an often used Function, using "Expand" might be
> nearly every time an Overkill.
>
> Maybe there is a quick "pretest", checking
> for the "simple power-product-form"
> a = a1^k1*...an^kn, a1,..an Symbols or Constants,
> k1..kn non negative integers?
>
> Greetings,
>   Detlef
>
>
>



  • Prev by Date: RE: Plotting multiple functions with different plot ranges?
  • Next by Date: RE: common factors in a matrix
  • Previous by thread: Re: MonomialQ
  • Next by thread: Automatic restart