       Replacement problem

• To: mathgroup at smc.vnet.net
• Subject: [mg36906] Replacement problem
• From: carlos at colorado.edu (Carlos Felippa)
• Date: Tue, 1 Oct 2002 04:46:03 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```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: Re: Kernel API
• Next by Date: Re: Colored ListPlot
• Previous by thread: Re: Kernel API
• Next by thread: Re: Replacement problem