Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Replacement gyrations

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

>-----Original Message-----
>From: carlos at [mailto:carlos at] 
To: mathgroup at
>Sent: Friday, April 08, 2005 7:37 AM
>To: mathgroup at
>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
>            (-(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:

Map[Factor, Wsol, {4}] /. x32*y21 - x21*y32 -> -2*A123
{{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:

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

Map[Factor, Wsol, {4}] /. FactorSpurious[(-(x32*y21) + x21*y32) ->
{{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