Re: Common factors in a list

*To*: mathgroup at smc.vnet.net*Subject*: [mg58366] Re: Common factors in a list*From*: David Bailey <dave at Remove_Thisdbailey.co.uk>*Date*: Tue, 28 Jun 2005 21:56:59 -0400 (EDT)*References*: <d9r50q$568$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

John Reed wrote: > I'm working with a list (vector) that's composed of functions such as > complex exponentials and Bessel functions. Some of the functions are common > to each element of the list. I'm trying to find a way to do the following: > > {a x, a y, a z}-> a *{x, y, z} > > In this expression, a, x, y, z are polynomials, exponentials and/or Bessel > functions. > > So far I haven't had any luck with this. Does anyone have a simple > solution? > > John Reed > Hello, The best bet is to make use of Factor. This seems rather more powerful than the help might suggest - for example it recognises that Exp[a+b] is Exp[a]Exp[b]. To use Factor, convert the list into a polynomial in an otherwise unused variable - say q: Plus@@MapIndexed[#1 q^(#2[[1]]-1)&,{a Exp[m],b Exp[m+n], c Exp[m]}] a*E^m + b*E^(m + n)*q + c*E^m*q^2 Factor[%] E^m*(a + b*E^n*q + c*q^2) It is not possible to convert the result back into a product of a term and a list (as you specified) because this will evaluate and leave you where you began! Instead, we can replace the product with a CircleTimes: E^m*(a + b*E^n*q + c*q^2) /. (p1_)*(p2_Plus) :> p1 \[CircleTimes] CoefficientList[p2, q] E^m \[CircleTimes] {a, b*E^n, c} David Bailey http://www.dbaileyconsultancy.co.uk