Re: Beginner--[Please Help]How to get coefficient list issued from a Series Command
- To: mathgroup at smc.vnet.net
- Subject: [mg70173] Re: Beginner--[Please Help]How to get coefficient list issued from a Series Command
- From: dimmechan at yahoo.com
- Date: Fri, 6 Oct 2006 01:58:53 -0400 (EDT)
- References: <eg2e8k$73m$1@smc.vnet.net>
Hello. What you need is very easy. But in order to do programming I need to modify a little your K list. For example the first element of the list, a1+b1 x +c1 x^2 was modified to a[1]+b[1]x+c[1]x^2 which apart for issues of programming is the proper one since as said you deal with power series. First define the list lst = (a[#1] + b[#1]*x + c[#1]*x^2 & ) /@ Range[3] {a[1] + x*b[1] + x^2*c[1], a[2] + x*b[2] + x^2*c[2], a[3] + x*b[3] + x^2*c[3]} Then use Cases Cases[lst, a[_], Infinity] {a[1], a[2], a[3]} Cases[lst, b[_], Infinity] {b[1], b[2], b[3]} Cases[lst, c[_], Infinity] {c[1], c[2], c[3]} and here is the desired user-defined function selectCoeff[lis_List, x_] := Cases[lis, x[_], Infinity] (*check*) selectCoeff[lst, a] {a[1], a[2], a[3]} If you insist on taking the result as {a1,a2,a3} (bad for you...) type % /. {a[1] -> a1, a[2] -> a2, a[3] -> a3} {a1, a2, a3} Regards Dimitris