Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*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 2005

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

Search the Archive

Re: Checking for a given phrase in an expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg60768] Re: Checking for a given phrase in an expression
  • From: dh <dh at metrohm.ch>
  • Date: Wed, 28 Sep 2005 01:41:03 -0400 (EDT)
  • References: <dhau80$is9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

HI,
in general this is not possible. Mathematically it is in general not 
even possible to decide if two expressions are identical or not.
Mathematica can compare patterns. Now consider the FullForm :
FullForm[1 + x + x y + Log[Sin[z]]]
--> Plus[1, x, Times[x, y], Log[Sin[z]]]
FullForm[x + Log[Sin[z]]]
--> Plus[x, Log[Sin[z]]]
you see the smaller pattern does not occur in the larger one. If you 
want detect the sub-pattern you would have to interprete the pattern for 
meaning, something Mathematica can not do.
Of course if you are searching for a simplier pattern like: Log[Sin[z]], 
that is contained in the FullForm of the larger expression, Mathematica will be 
able to find it (e.g. with Position).

If you really are a "workoholic" a could create a pattern recognition 
system that can recognize a limited set of patterns by defining a 
suitable "Normalform" for your expressions that would allow to 
mechanically decide if a searched pattern is contained or not.

sincerely, Daniel


lost.and.lonely.physicist at gmail.com wrote:
> Hello everyone
> 
> Is it possible to ask Mathematica to check if a given phrase occurs in
> an expression? Say I have
> 
> aa = 1 + x + x y + Log[Sin[z]]
> 
> and
> 
> bb = x + Log[Sin[z]]
> 
> Can Mathematica tell me such a phrase bb exists in aa? Can it tell me
> its 'position' within the expression aa?
> 
> Thanks for the help!
> 


  • Prev by Date: Re: Checking for a given phrase in an expression
  • Next by Date: SVG Authoring Tool Chain Report
  • Previous by thread: Re: Checking for a given phrase in an expression
  • Next by thread: Re: Re: Checking for a given phrase in an expression