MathGroup Archive 2007

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

Search the Archive

Re: Substituting simpler expressions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78697] Re: Substituting simpler expressions
  • From: dimitris <dimmechan at yahoo.com>
  • Date: Sat, 7 Jul 2007 06:01:07 -0400 (EDT)
  • References: <f6krve$l9o$1@smc.vnet.net>

            Steve Gray       :
> Suppose I  have a long complex expression in which the term
> exx=Sqrt[x^2+y^2-xy] (for example) appears many times. I would like to
> substitute say "rootxy" (for example) for it everywhere it appears. I
> know about doing exx/.Sqrt[x^2+y^2-xy]-> rootxy but that doesn't do
> it. Any tips? Thank you.
>
> Steve Gray

Hi.

It would be better to show us your expression.

Let's create an expression

In[179]:=
Table[x^m*y^n, {m, 1, 5}, {n, 1, 3}]
o = Sin[x*y]*Sqrt[x^2 + y^2 - xy]*(x^2 + y^2 - xy)^(3/2) + Expand[Plus
@@ Apply[Times, %, {1}]*Sqrt[x^2 + y^2 - xy]]

Out[179]=
{{x*y, x*y^2, x*y^3}, {x^2*y, x^2*y^2, x^2*y^3}, {x^3*y, x^3*y^2,
x^3*y^3}, {x^4*y, x^4*y^2, x^4*y^3},
  {x^5*y, x^5*y^2, x^5*y^3}}

Out[180]=
x^3*y^6*Sqrt[x^2 - xy + y^2] + x^6*y^6*Sqrt[x^2 - xy + y^2] +
x^9*y^6*Sqrt[x^2 - xy + y^2] + x^12*y^6*Sqrt[x^2 - xy + y^2] +
x^15*y^6*Sqrt[x^2 - xy + y^2] + (x^2 - xy + y^2)^2*Sin[x*y]

Then

In[181]:=
o /. Sqrt[x^2 - xy + y^2] -> met

Out[181]=
met*x^3*y^6 + met*x^6*y^6 + met*x^9*y^6 + met*x^12*y^6 + met*x^15*y^6
+ (x^2 - xy + y^2)^2*Sin[x*y]

Is this what do you want?

Dimitris



  • Prev by Date: Re: Mathematica forgets a solution in DSolve!!!
  • Next by Date: Re: How to plot a graph in a non-Cartesian coordinate?
  • Previous by thread: Re: Substituting simpler expressions
  • Next by thread: Re: Substituting simpler expressions