Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive


  • To: mathgroup at
  • Subject: [mg46417] Re:
  • From: Andrzej Kozlowski <akoz at>
  • Date: Tue, 17 Feb 2004 07:05:48 -0500 (EST)
  • References: <>
  • Sender: owner-wri-mathgroup at

On 17 Feb 2004, at 05:41, Oleksandr Pavlyk wrote:

> Just curious, is it to be considered a bug that
> In[1]:= FreeQ[-1 (a+b), a+b ]
> Out[1]= True
> and at the same time
> In[2]:=FreeQ[ -2 (a+b), a+b ]
> Out[2]= False
> I would appereciate community's opinion on the issue.
> Thank you,
> Sasha
To understand pattern matching you always look at FullForm:

FullForm[-1 (a+b)]


As you can see yourself there is not Plus[a,b] here.


FullForm[-2 (a+b)]


This time the reason for the difference is that -1(a+b) is always 
automatically expanded to -a - b





-2 (a+b)

is not expanded. Of course you can prevent evaluation in the former 
case if you want to:



In any case, in my opinion there is no problem here. Pattern matching 
uses the FullForm of expressions, so in all cases you need to 
understand FullForm before trying to use it and often it will not be 
what you expect.

Andrzej Kozlowski
Chiba, Japan

  • Prev by Date: RE:
  • Next by Date: Re: A zillion times slower in version 5
  • Previous by thread: RE:
  • Next by thread: Maximum Likelihood Problem