Re: List Manipulation

*To*: mathgroup at smc.vnet.net*Subject*: [mg72419] Re: [mg72407] List Manipulation*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Wed, 27 Dec 2006 05:35:07 -0500 (EST)*References*: <200612250952.EAA14907@smc.vnet.net>

On 25 Dec 2006, at 18:52, Stratocaster wrote: > I'm not sure if the following is possible or whether it exists > somewhere > between the realms of fantasy and science fiction. I have been > unable to do > it. > > Given a list, set, vector (whatever you want to call it) consisting of > functions of the same variable, i.e. > > list = {a1+b1*k, a2+b2*k, a3+b3*k...} > > Assuming they are all linear (of the form a+b*k) is there away to > isolate > the a_i and b_i values? Essentially I would like to get a list "A" > consisting of all the intercept values, and a list "B" consisting > of all the > slope values. > > Is this possible? What kind of operations do I need to use to > accomplish > this (if indeed it is possible)? > > Thanks for any insights. > If I understand you correctly this function gives one (out of a large number) of ways of doing this: f[ls_] := Transpose[Map[{Coefficient[#, k, 0], Coefficient[#, k, 1]} &, ls]] Let's take two sample lists, one with numeric and one with symbolic coefficients: ls1={2+3 k,1-0.5k,4+Pi k}; ls2={a+b k,c+d k,e+f k}; Then f[ls1] {{2, 1, 4}, {3, -0.5, Pi}} f[ls2] {{a, c, e}, {b, d, f}} Andrzej Kozlowski Tokyo, Japan

**References**:**List Manipulation***From:*"Stratocaster" <stotz1@verizon.net>