Re: Replacement question
- To: mathgroup at smc.vnet.net
- Subject: [mg74219] Re: [mg74156] Replacement question
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 14 Mar 2007 03:58:54 -0500 (EST)
- Reply-to: hanlonr at cox.net
Convert the rule to one with an atomic expression on the LHS., i.e., "solve" the replacement rule for one of the other variables, preferably a variable which only occurs in the form to be replaced. So {y+z -> x} goes to either {y -> x-z} or {z -> x-y}
(y+z)^2+3(y+z)-y+z /. z\[Rule]x-y
x^2 + 4*x - 2*y
Bob Hanlon
---- Brian Beckage <Brian.Beckage at uvm.edu> wrote:
> I apologize for this very basic question. I understand how to use /.
> {} to replace a variable with a more complex expression, e.g., x->
> y+z. Can one move in the opposite direction to replace all
> occurrences of y+z with x? myExpression/.{y+z->x} does not seem to
> work.
>
> Thank you for your help,
> Brian
>
>
>
> --
> *********************************************************************
> Brian Beckage
> Department of Plant Biology
> University of Vermont
> Marsh Life Science Building
> Burlington, VT 05405
> *********************************************************************
>