MathGroup Archive 2006

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

Search the Archive

Re: Extracting terms from an equation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69826] Re: Extracting terms from an equation
  • From: albert <awnl at arcor.de>
  • Date: Sat, 23 Sep 2006 23:45:40 -0400 (EDT)
  • References: <eevubf$hqu$1@smc.vnet.net> <ef2t04$mjc$1@smc.vnet.net>

Hi,

> Cases[a + b*x^2 + c*y^2 + d*x*y + e*x^3, _?( !FreeQ[#1, x] & )]
> {b*x^2, e*x^3, d*x*y}
> 
> Cases[a + b*x^2 + c*y^2 + d*x*y + e*x^3, _?(MemberQ[#1, x] & )]
> {d*x*y}

MemberQ by default checks for precense of x in the first level only. What
you probably want is:

Cases[a + b*x^2 + c*y^2 + d*x*y + e*x^3, _?(MemberQ[#1, x,Infinity] & )]

which should always give the same result as the version with FreeQ. Use

In[4]:= FullForm[e*x^3]
Out[4]//FullForm=
Times[e, Power[x, 3]]

to understand why x is not a member of e*x^3 , but x^3 is...


hth,

albert


  • Prev by Date: Re: DSolve fails with Telegraph equation
  • Next by Date: Re: Add Quotation Marks to Data in a file
  • Previous by thread: Re: Re: Extracting terms from an equation
  • Next by thread: Re: Re: Extracting terms from an equation