MathGroup Archive 2002

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

Search the Archive

Re: Replacement problem


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