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: Simplifying an expression in light of relationships between variables?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg54273] Re: [mg54263] Simplifying an expression in light of relationships between variables?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Wed, 16 Feb 2005 14:35:54 -0500 (EST)
  • References: <200502150251.VAA27353@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

*This message was transferred with a trial version of CommuniGate(tm) Pro*
On 15 Feb 2005, at 03:51, Steve W. Brewer wrote:

> Suppose I have a few variables that are related in the following way:
>
> d == a + b
> e == c + d
>
>
>
> I want Simplify and FullSimplify to consider these relationships when
> performing simplification.  For example:
>
> FullSimplify[a + b]
>
> d
>
>
>
> FullSimplify[d - b]
>
> a
>
>
>
> FullSimplify[a + b + c]
>
> e
>
>
>
> FullSimplify[e - c]
>
> d
>
>
>
> FullSimplify[e - c - b]
>
> a
>
>
>
> Is there a straightforward way to get this behavior?  I've tried
> experimenting with TransformationFunctions, but it looks like I need to
> include every possible permutation for it to work, for example:
>
> TransformationFunctions ->
>    {Automatic,
>     # /. (d -> a + b)&,
>     # /. (a + b -> d)&,
>     # /. (a -> d - b)&,
>     # /. (d - b -> a)&,
>     # /. (b -> d - a)&,
>     # /. (d - a -> b)&,
>     ... }
>
>
>
> This is unwieldy even in this simple example, and it rapidly becomes
> unmanageable as the number of variables and relationships increases.
>
>
> Is there an easier way?
>
>
>

In an earlier thread Adam Strzebonski of WRI posted a function 
(Variable Order Independent Simplify) that does this:

VOISimplify[vars_, expr_, assum_:True] :=
     Module[{perm, ee, best},
        perm = Permutations[vars];
        ee = (FullSimplify @@ ({expr, assum} /. Thread[vars -> #])) & /@ 
perm;
        best = Sort[Transpose[{LeafCount /@ ee, ee, perm}]][[1]];
        best[[2]] /. Thread[best[[3]] -> vars]]


VOISimplify[{a,b,c,d},d-b,{d==a+b,e==c+d}]

a


VOISimplify[{a, b, c, d}, a + b + c,
   {d == a + b, e == c + d}]

e


Andrzej Kozlowski
Chiba, Japan
http://www.akikoz.net/~andrzej/
http://www.mimuw.edu.pl/~akoz/


  • Prev by Date: Re: Axes in ShowGraph
  • Next by Date: Re: Simplifying an expression in light of relationships between variables?
  • Previous by thread: Simplifying an expression in light of relationships between variables?
  • Next by thread: Re: Simplifying an expression in light of relationships between variables?