[Date Index]
[Thread Index]
[Author Index]
Re: Re: Extracting terms from an equation
*To*: mathgroup at smc.vnet.net
*Subject*: [mg69822] Re: [mg69786] Re: Extracting terms from an equation
*From*: "Carl K. Woll" <carlw at wolfram.com>
*Date*: Sat, 23 Sep 2006 23:45:30 -0400 (EDT)
*References*: <eevubf$hqu$1@smc.vnet.net> <200609230844.EAA22454@smc.vnet.net>
dimmechan at yahoo.com wrote:
> Can someone explain the difference in the following?
>
> 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 has a default level specification of {1}, while FreeQ has a
default level specification of {0,Infinity}. If one uses the same level
specifications, then !FreeQ and MemberQ are equivalent:
expr = a + b*x^2 + c*y^2 + d*x*y + e*x^3;
Give FreeQ the level spec (1):
In[27]:= Cases[expr, _?(! FreeQ[#1, x, {1}] &)] ==
Cases[expr, _?(MemberQ[#1, x] &)]
Out[27]= True
Give MemberQ the level spec {0,Infinity}:
In[28]:= Cases[expr, _?(! FreeQ[#1, x] &)] ==
Cases[expr, _?(MemberQ[#1, x, {0, Infinity}] &)]
Out[28]= True
Carl Woll
Wolfram Research
> Thanks
>
> Î?/Î? Coleman, Mark ÎÎ³Ï?Î±Ï?Îµ:
>> Greetings,
>>
>> I'd like to find a general way to extract all of the terms from an
>> equation that involve a given variable. For instance, consider the
>> equation
>>
>> myEquation == Exp[a + b x^2 + c y^2 + d x y + e x^3]]
>>
>> I'd like to define a function such that
>>
>> myFunction[myEquation,x] returns the result {b x^2, d x y, e x^3}
>>
>> Thanks,
>>
>> -Mark
Prev by Date:
**Re: Pure function in a pure function (again)**
Next by Date:
**RE: Table command strange output when 'i' over 16**
Previous by thread:
**Re: Extracting terms from an equation**
Next by thread:
**Re: Extracting terms from an equation**
| |