MathGroup Archive 2010

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

Search the Archive

Re: Substitute expressions with FullSimplify

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108687] Re: Substitute expressions with FullSimplify
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Sat, 27 Mar 2010 05:11:26 -0500 (EST)
  • References: <hoi2n9$qj7$1@smc.vnet.net>

"Guido Walter Pettinari" <coccoinomane at gmail.com> wrote in message 
news:hoi2n9$qj7$1 at smc.vnet.net...
> Hello world!
>
> This is my first post in this group, but it has been a while since I
> started reading it. I always found it quite useful, therefore I wish
> to thank everibody for their contributions!
>
> Here is my problem. Let's say I have an expression. I would like to
> substitute all the occurences of a given subexpression in this
> expression with a symbol. I want to do it in an intelligent way, i.e.
> by using FullSimplify instead of ReplaceAll.
>
> If my expression is:
>
> x^2 + y^2
>
> I know that:
>
> FullSimplify [ x^2 + y^2,   x^2 + y^2 == r ]
>
> will produce 'r' as a result, which is what I want.
>
> However, if my expression is
>
> x + y ,
>
> then
>
> FullSimplify [ x + y,   x + y == r ]
>
> produces 'x + y' and not 'r' ! I tried to use
>
> FullSimplify [ x + y,   x + y == r, ComplexityFunction -> LeafCount ]
>
> but I still get 'x+y' as a result.
>
> Do you have any idea on how to substitute x+y with r in an expression?
>

Good question. I do not know myself, may be a Mathematica expert can tell 
us. But I am just curious, why do you consider

Simplify [ x + y,   x + y == r ]

more "intelligent" than

In[39]:= x + y /. {x + y -> r}
Out[39]= r

?

--Nasser




  • Prev by Date: Re: Mathematica starts badly 1 time over 5 in OSX
  • Next by Date: Re: 15! permutations
  • Previous by thread: Substitute expressions with FullSimplify
  • Next by thread: Re: Substitute expressions with FullSimplify