MathGroup Archive 2005

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

Search the Archive

Re: Replacement gyrations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55885] Re: [mg55872] Replacement gyrations
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Sat, 9 Apr 2005 03:55:21 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: carlos at colorado.edu [mailto:carlos at colorado.edu] 
To: mathgroup at smc.vnet.net
>Sent: Friday, April 08, 2005 7:37 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg55885] [mg55872] Replacement gyrations
>
>A Solve for 4 variables W11,W12,W21,W22 produces, after Simplify
>
> Wsol={{W11 -> (A2*x21 + A1*x32)/(L86^2*(-(x32*y21) + x21*y32)),
>        W12 -> (A2*y21 + A1*y32)/(-(L86^2*x32*y21) + L86^2*x21*y32),
>        W21 -> (A2*x21 + A1*x32)/(L75^2*(-(x32*y21) + x21*y32)),
>        W22 -> (A2*y21 + A1*y32)/(-(L75^2*x32*y21) + L75^2*x21*y32)}}
>
>Question 1: why do L86^2 and L75^2  come out as a factor in two
>expression denominators and not in the others?  Seems a random event.
>
>This uncertainty inhibits the action of further replacement rules such
>as
>            (-(x32*y21) + x21*y32) -> 2*A123
>
>which works on W11 and W21 only.
>
>Question 2: I tried Collect [Wsol,{L86,L75}] to try to force grouping
>of L86^2 and L75^2, but it has no effect.
>Do I need to say Wsol=Wsol*L86^2*L75^2, Simplify, replace and finally
>Wsol=Wsol/L86^2*L75^2 ? Or fool around with Numerator and Denominator?
>
>

There are two different problems associated with this, one is for
factoring, the other for pattern matching. this e.g. works:

In[19]:=
Map[Factor, Wsol, {4}] /. x32*y21 - x21*y32 -> -2*A123
Out[19]=
{{W11 -> (A2*x21 + A1*x32)/(2*A123*L86^2), 
   W12 -> (A2*y21 + A1*y32)/(2*A123*L86^2), 
   W21 -> (A2*x21 + A1*x32)/(2*A123*L75^2), 
   W22 -> (A2*y21 + A1*y32)/(2*A123*L75^2)}}

For factoring we just map Factor to the right level of the expression.
Your pattern then however doesn't match. The reason becomes clear if you
look at the FullForms of the expression and the pattern.

Even the pattern Factor[c_. (-x32*y21 + x21*y32)] still won't match, as
this contains an explicit factor -1 (from factoring) which is not
present in the expression and such prevents matching.

Of course you may try both signs by hand, or automate that:

In[56]:=
FactorSpurious[p_ -> t_] := {Factor[c_. p] -> c t, Factor[-c_. p] -> -c
t}


In[58]:=
Map[Factor, Wsol, {4}] /. FactorSpurious[(-(x32*y21) + x21*y32) ->
2*A123]
Out[58]=
{{W11 -> (A2*x21 + A1*x32)/(2*A123*L86^2), 
   W12 -> (A2*y21 + A1*y32)/(2*A123*L86^2), 
   W21 -> (A2*x21 + A1*x32)/(2*A123*L75^2), 
   W22 -> (A2*y21 + A1*y32)/(2*A123*L75^2)}}

--
Hartmut Wolf


  • Prev by Date: Re: Replacement gyrations
  • Next by Date: Re: Having trouble with substitution tile at higher iteration levels--> takes forever!
  • Previous by thread: Re: Replacement gyrations
  • Next by thread: Re: Replacement gyrations