Re: Naming pieces of patterns
- To: mathgroup at smc.vnet.net
- Subject: [mg29841] Re: Naming pieces of patterns
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 13 Jul 2001 04:19:22 -0400 (EDT)
- References: <9ijhj3$rhj$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Cyril, Unevaluated[-(1/(2a))]/. HoldPattern[ 1/(2 a)]\[Rule]A -A Unevaluated[{(a+b),-(a+b)}]/.a+b\[Rule] e {e, -e} Unevaluated[{-Sqrt[a+b],1/Sqrt[a+b]}]/.HoldPattern[Sqrt[a+b]]\[Rule]e {-e, 1/e} Unevaluated[{I,2 I,-I}]/.HoldPattern[I]\[Rule]J {J, 2*J, -J} {I,2 I,-I}/.Complex[0,y_]->y J {J, 2*J, -J} -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Cyril Fischer" <fischerc at itam.cas.cz> wrote in message news:9ijhj3$rhj$1 at smc.vnet.net... > How can I as simply as possible use "substitutions" > 1. > -(I/(2 a)) /. I/(2 a) -> A > does not work, while > (I/(2 a)) /. I/(2 a) -> A > works well > > 2. > {(a + b), -(a + b)}/. a + b -> e > gives > {e, -a - b} > instead of {e,-e} > > 3. > {-Sqrt[a + b], 1/Sqrt[a + b]} /. Sqrt[a + b] -> e > gives > {-e,1/Sqrt[a + b]} > > 4. > {I, 2 I, -I} /. I -> J > gives > {J, 2 \[ImaginaryI], -\[ImaginaryI]} > > I know _why_ these cases do not work, but I would like to know, if there > is a possibilty to use a common pattern rule to substitute all > occurences of an expression. > > Thank you, > Cyril Fischer > >