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: [mg54299] Re: [mg54263] Simplifying an expression in light of relationships between variables?
  • From: Chris Chiasson <chris.chiasson at gmail.com>
  • Date: Wed, 16 Feb 2005 14:36:25 -0500 (EST)
  • References: <200502150251.VAA27353@smc.vnet.net>
  • Reply-to: Chris Chiasson <chris.chiasson at gmail.com>
  • Sender: owner-wri-mathgroup at wolfram.com

(During the morning, I originally sent a reply to Steve only; delivery
failed. I "corrected" his email address and I have also carbon copied
MathGroup.)


Steve W. Brewer,

Here is a solution, though it is not particularly efficient:

(Input)
junk={d==a+b,e==c+d,g==f+e}
(Output)
{d == a + b, e == c + d, g == e + f}

(Input)
gunk=Map[Variables,junk/.Equal[x_,y_]->{x,y},{2}]//Flatten//Union
(Output)
spelling error message
{a, b, c, d, e, f, g}

(Input)
Needs["DiscreteMath`Combinatorica`"]

(Input)
AdditionalTransformationFunctions=
 Union@Map[Function[{simplification},#/.simplification&],
     Flatten[Function[{solvevariable},
           Function[{elimination},
               Solve[Eliminate[junk,elimination],solvevariable]]/@
             KSubsets[DeleteCases[gunk,solvevariable],Length[junk]-1]]/@
         gunk]]
(Output)
{#1 /. a -> -b + d & , #1 /. a -> -b - c + e & ,
#1 /. a -> -b - c - f + g & , #1 /. b -> -a + d & ,
#1 /. b -> -a - c + e & ,
#1 /. b -> -a - c - f + g & ,
#1 /. c -> -a - b + e & , #1 /. c -> -d + e & ,
#1 /. c -> -a - b - f + g & ,
#1 /. c -> -d - f + g & , #1 /. d -> a + b & ,
#1 /. d -> -c + e & , #1 /. d -> -c - f + g & ,
#1 /. e -> a + b + c & , #1 /. e -> c + d & ,
#1 /. e -> -f + g & , #1 /. f -> -a - b - c + g & ,
#1 /. f -> -c - d + g & , #1 /. f -> -e + g & ,
#1 /. g -> a + b + c + f & ,
#1 /. g -> c + d + f & , #1 /. g -> e + f & }

(Input)
Simplify[e-c-b,
 TransformationFunctions->
   Flatten[{Automatic,AdditionalTransformationFunctions}]]
(Output)
a

By the way, this method of doing things seems to be fairly crazy... If
you don't mind me asking, what are you going to do with this code?

Regards,


On Mon, 14 Feb 2005 21:51:04 -0500 (EST), Steve W. Brewer
<ste-ve at ka-tech.com> 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?
> 
> 


-- 
Chris Chiasson
Kettering University
Mechanical Engineering
Graduate Student
1 810 265 3161


  • Prev by Date: Re: problem with FindRoot
  • Next by Date: Re: Re: Re: 64-bit pentium
  • Previous by thread: Re: Simplifying an expression in light of relationships between variables?
  • Next by thread: Re: Simplifying an expression in light of relationships between variables?