Re: Replacing an expression by an expression
- To: mathgroup at smc.vnet.net
- Subject: [mg55645] Re: Replacing an expression by an expression
- From: dh <dh at metrohm.ch>
- Date: Fri, 1 Apr 2005 05:36:17 -0500 (EST)
- References: <d2g6d7$f7p$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Carlos,
in your example yout try to match -(..(-x32-x43)+..) by (..((x32+x43)-..)
ReplaceAll replaces pattern, not mathematical objects. Further, what you
see is not exactly the same what Mathematica uses. "FullForm[expr]"
shows you what Mathematica is using.
Therefore, this will not work:
-(c(-a-b)) /. (a+b)->w
because
FullForm[-(c(-a - b) )] is Times[-1, Plus[Times[-1, a], Times[-1, b]],
and
FullForm[a+b] is Plus[a, b]
You see the Pattern Plus[a,b] does not appear in the above expression.
Sincerely, Daniel
carlos at colorado.edu wrote:
> I have a 8 x 8 symbolic matrix B of complicated entries.
> Several partial expressions, however, can be simplified. Sample:
>
> rep= {(J12*x14-J11*y14)*(J12*(x32+x43)-J11*(y32+y43)) -> A0*(A1-A0)};
>
> The left expression appears verbatim in entry B[[1,1]], which is
>
> -(L21*(J12*x14-J11*y14)*(J12*(-x32-x43)+J11*(y32+y43)))/
> (16*A412*J*(J11^2+J12^2))
>
> But when I say B=B/.rep, nothing happens. For a few entries I could do
> cut and paste by hand:
>
> -(L21* A0*(A1-A0) )/
> (16*A412*J*(J11^2+J12^2))
>
> But it get tedious and error prone for 64. Any suggestions on how to
> get Mathematica to do the replacement?
>