       Re: List Manipulation

• To: mathgroup at smc.vnet.net
• Subject: [mg72430] Re: List Manipulation
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Wed, 27 Dec 2006 06:19:21 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <emo866\$g29\$1@smc.vnet.net>

```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.
>
Among many other possibilities, you could try one of the following:

In:=
list = {a1 + b1*k, a2 + b2*k, a3 + b3*k}

Out=
{a1 + b1*k, a2 + b2*k, a3 + b3*k}

In:=
(Select[#1, FreeQ[#1, k] & ] & ) /@ list

Out=
{a1, a2, a3}

In:=
(Select[#1,  !FreeQ[#1, k] & ] & ) /@ list/k

Out=
{b1, b2, b3}

In:=
list /. (p_) + (q_)*k -> p

Out=
{a1, a2, a3}

In:=
list /. (p_) + (q_)*k -> q

Out=
{b1, b2, b3}

Happy holidays,
Jean-Marc

```

• Prev by Date: [resend] large input to NMinimize causes NMinimize:"bcons" along with Less:nord ... and I don't think it should
• Next by Date: Re: nestled plotting
• Previous by thread: Re: List Manipulation
• Next by thread: RE: List Manipulation