Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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

RE:

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46412] RE:
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 17 Feb 2004 07:05:45 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Sasha,

Definitely not a bug because pattern matching, not algebra, is involved.

a + b // FullForm
Plus[a, b]

-1(a + b) // FullForm
Plus[Times[-1, a], Times[-1, b]]

-2(a + b) // FullForm
Times[-2, Plus[a, b]]

You could get something more to your liking by using the pattern

(a + b) | Expand[k_.(a + b)


testlist = {a + b, 2(a + b),
    2(a + b) // Expand, -(a + b), -2(a + b), -2(a + b) // Expand, k(a + b),
    k(a + b) // Expand, k1 a + k2 b}
{a + b, 2 (a + b), 2 a + 2 b, -a - b, -2 (a + b), -2 a - 2 b, (a + b) k,
  a k + b k, a k1 + b k2}

FreeQ[#, (a + b) | Expand[k_.(a + b)]] & /@ testlist
{False, False, False, False, False, False, False, False, True}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Oleksandr Pavlyk [mailto:pavlyk at phys.psu.edu]
To: mathgroup at smc.vnet.net

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



  • Prev by Date: Re: Printing Variables and Their Values
  • Next by Date: Re:
  • Previous by thread: Re: Solve or LinearSolve or ...?
  • Next by thread: Re: