RE: Factorising
- To: mathgroup at smc.vnet.net
- Subject: [mg38943] RE: [mg38954] Factorising
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Wed, 22 Jan 2003 06:09:49 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: Chris Rodgers [mailto:christopher.rodgers at st-johns.oxford.ac.uk] To: mathgroup at smc.vnet.net >Sent: Tuesday, January 21, 2003 1:40 PM >To: mathgroup at smc.vnet.net >Subject: [mg38943] [mg38954] Factorising > > >Hi > >How can I tell Mathematica to pull a particular factor out of >an expression. > >For example in this expression: >{(a - 2*wone*Sin[a*t])/4, (a - 2*wone*Sin[a*t])/4, (a + >2*wone*Sin[a*t])/4, >(a + 2*wone*Sin[a*t])/4, > (-a - 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a - 2*Sqrt[a^2 + >wone^2*Sin[a*t]^2])/4, > (-a + 2*Sqrt[a^2 + wone^2*Sin[a*t]^2])/4, (-a + 2*Sqrt[a^2 + >wone^2*Sin[a*t]^2])/4} > >I would like to bring the "a" out to the front of the expression, even >outside the matrix. > >How can I ask Mathematica to do this, and how can I stop the "a" just >floating back into the main expression? > >Yours > >Chris Rodgers >St John's College >http://rodgers.org.uk/ > > > Chris, The problem comes from the Listable attribute of Plus. If you want to see your expression (which I call alist for a while) as you want, you can clear that Attribute for a while: ClearAttributes[Plus, Listable] Thread[Apart[alist], Plus] Now, I think, you see what you want. The procedure is dangerous however, since the attributes of Plus should be restored, before you make any other evaluation. SetAttributes[Plus, Listable] Assuming you need that form only for printing purposes, it might be more convenient just to wrap it into HoldForm: Block[{Plus}, HoldForm[#] &[Thread[Sort /@ Apart[alist], Plus]]] The Block temporarily inactivates Plus (and its attributes), HoldForm prevents threading back to the original form, after the expression having left Block. -- Hartmut Wolf