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

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

Search the Archive

Re: Simplifying expressions for use in C programs

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22070] Re: [mg22051] Simplifying expressions for use in C programs
  • From: Wagner Truppel <wtruppel at uci.edu>
  • Date: Sat, 12 Feb 2000 04:04:29 -0500 (EST)
  • 1message-id: <v04220803b4c9828b203c@128.195.182.195>
  • References: <200002110738.CAA04794@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On a previous post, I said

>My biggest problem is actually recognizing sub-expressions that
>appear frequently. Performing that simplification would save a
>substantial amount of computation given the expressions I'm dealing
>with.

Since then, I came up with this:

GetSubExpressions[z_] :=
     Module[{x},
       x = Cases[z, _Plus,  { 1, \[Infinity] }];
       x = Union[Flatten[x]];
       Return[x];
       ];

It finds all sub-expressions surrounded by (), ie, it returns b + c 
when applied to things like a*(b + c) and (b + c)^3, but leaves the 
problem of finding common terms not surrounded by () still unsolved.

Wagner Truppel
wtruppel at uci.edu



  • Prev by Date: Re: Re: Orientation of characters in FrameLabel
  • Next by Date: Re: Default values / optional parameters
  • Previous by thread: Simplifying expressions for use in C programs
  • Next by thread: Re: Simplifying expressions for use in C programs