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

**References**:**Simplifying expressions for use in C programs***From:*Wagner Truppel <wtruppel@uci.edu>