MathGroup Archive 2002

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

Search the Archive

Re: Replacement problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36908] Re: Replacement problem
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Wed, 2 Oct 2002 03:31:27 -0400 (EDT)
  • Organization: Universitaet Leipzig
  • References: <anbop9$e93$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,


Sqrt[a] is internal Power[a,Rational[1,2]] and
1/Sqrt[a] is interal Power[a,Rational[-1,2]] 
and so a rule Sqrt[a]->q will not match with
1/Sqrt[a]. You need

f = B*(A + Sqrt[X + Y + Z]) + C/(Sqrt[X + Y + Z]/4*F^2);
(f /. (X + Y + Z)^Rational[n_, 2] -> Q^n)

Regards
  Jens



Carlos Felippa wrote:
> 
> These expressions are condensation of larger ones
> (about 700 lines or so each) but they illustrate random
> substitution failures in 4.2.  Question: how can the
> substitution Sqrt[...]->Q always be made to work?
> The help file under ReplaceAll, ReplaceRepeated, etc,
> does not address this problem.
> 
> Thanks
> 
> f=B*(A+Sqrt[X+Y+Z])+C/(Sqrt[X+Y+Z]/4*F^2);
> Print[(f/.Sqrt[X+Y+Z]->Q)//InputForm];
> 
> B*(A + Q) + (4*C)/(F^2*Sqrt[X + Y + Z])  (* fails *)
> 
> g=B*(A+Sqrt[X+Y+Z])+C/(Sqrt[X+Y+Z]*4*F^2);
> Print[(g/.Sqrt[X+Y+Z]->Q)//InputForm];
> 
> B*(A + Q) + C/(4*F^2*Sqrt[X + Y + Z])    (* fails *)
> 
> h=B*(A+Sqrt[X+Y+Z])+C/(Sqrt[X+Y+Z]+4*F^2);
> Print[(h/.Sqrt[X+Y+Z]->Q)//InputForm];
> 
> B*(A + Q) + C/(4*F^2 + Q)                (* works *)


  • Prev by Date: Text Rotation Problem
  • Next by Date: FindRoot on complex 'interval'
  • Previous by thread: Replacement problem
  • Next by thread: RE: Replacement problem