Re: How to substitute?
- To: mathgroup at smc.vnet.net
- Subject: [mg45498] Re: How to substitute?
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Sat, 10 Jan 2004 00:00:48 -0500 (EST)
- References: <firstname.lastname@example.org>
- Sender: owner-wri-mathgroup at wolfram.com
Your examples appear inconsistent (y-z or z-y?). However, you should be able to modify the following for whatever your intended output. expr /. a_.* Subscript[y,i_] + b_.* Subscript[z,j_] :> Subscript[Q, a*i, b*j] expr /. a_. * y[i_] + b_. * z[j_] :> Q[a*i, b*j] Bob Hanlon In article <btndpp$4f$1 at smc.vnet.net>, Steve Gray <stevebg at adelphia.net> wrote: << \!\(\((y\_0 - z\_3)\)\ \((\(-y\_1\) + z\_3)\)\ \((\(-y\_2\) + z\_3)\)\ \((\(-y\_3\) + z\_3)\)\) I have output cells containing various expressions such as (y-z) (y-z) (y - z), where I use [x] here to mean subscript. The integers can have any small values. For compactness of expression, I want to make substitutions which make the above expression look like Q[0,1]Q[1,2]Q[4,0]. There are many combinations of subscript pairs and I don't want to write explicit substitution rules for every possible combination. I tried doing /.(y[i]-z[j]) -> Q[i,j] , and /.(y[i_]-z[j_]) -> Q[i,j] but they don't work. Any suggestions will be gratefully received.