• To: mathgroup at smc.vnet.net
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Sat, 4 Dec 2010 06:15:49 -0500 (EST)

```A simpler form:

expr1 == a1 + a2*x + a3*y + a4*x^2 + a5*x*y + a6*y^2;

myCoef[expr_, var_List] :==
SortBy[List @@ expr1, Total[Exponent[#, var]] &] /. Thread[var -> 1]

myCoef[expr1, {x, y}]

{a1, a2, a3, a4, a5, a6}

Bob Hanlon

---- Bob Hanlon <hanlonr at cox.net> wrote:

==========================

expr1 == a1 + a2*x + a3*y + a4*x^2 + a5*x*y + a6*y^2;

Since you apparently want to ignore zero coefficients then this extracts th=
e non-zero coefficients

(List @@ expr1) /. {x -> 1, y -> 1}

{a1, a2, a4, a3, a5, a6}

However, this standard ordering is different from yours. Presumably, your o=
rdering is

myCoef[expr_, var_List] :== Module[
{coef == (List @@ expr) /. Thread[var -> 1]},
Last /@ Sort[
Cases[List @@ expr,
a_?(MemberQ[coef, #] &)*z_. ->
{Total[Exponent[z, var]], a}]]];

myCoef[expr1, {x, y}]

{a1, a2, a3, a4, a5, a6}

Bob Hanlon

=8A=E0=B8=8A=E0=B9=8C =E0=B8=82=E0=B8=88=E0=B8=A3=E0=B8=A3=E0=B8=B8=E0=B9=
=88=E0=B8=87=E0=B8=A8=E0=B8=B4=E0=B8=A5=E0=B8=9B=E0=B9=8C" <kajornrungsilp.=
i at gmail.com> wrote:

==========================
Thank you for your answer. But I would like only the coefficient of series
equation in the form {a1, a2 , a3 ,a4,a5,a6} not to be in the form of {{a1,
a3, a6}, {a2, a5, 0}, {a4, 0, 0}}. How to get there?
Best regard

2010/12/3 Bob Hanlon <hanlonr at cox.net>

>
> expr1 == a1 + a2*x + a3*y + a4*x^2 + a5*x*y + a6*y^2;
>
> coef == CoefficientList[expr, {x, y}]
>
> {{a1, a3, a6}, {a2, a5, 0}, {a4, 0, 0}}
>
> From example in documentation on CoefficientList
>
> expr2 == Fold[FromDigits[Reverse[#1], #2] &, coef, {x, y}]
>
> a1 + a2 x + a4 x^2 + (a3 + a5 x) y + a6 y^2
>
> expr1 ==== expr2 // Simplify
>
> True
>
>
> Bob Hanlon
>
> ---- Autt <kajornrungsilp.i at gmail.com> wrote:
>
> ==========================
> Greeting,
> I've a list issued from  multivariate series like : K=={a1+a2*x +a3*y
> +a4*x^2*+a5*x*y +a6*y^2 }
> I need to have {a1, a2 , a3 ,a4,a5,a6}
>
>  How to do that please?
> e.g.
> n == 3
> u == Normal[Series[x^4 + y^4 + x^2, {x, 5, n}, {y, 5, n}]]
> c[0] == {};
> d == {};
> q[0] == {};
> For[k == 1 , k <== n - 1, k++,
>  For[i == 0 , i <== k , i++,
>  p[i, k - i] ==
>   SeriesCoefficient[u, {x, 5, i}, {y, 5, k - i}];
>  q[k] == Union[{q[k - 1], {p[i, k - i]}}];
>  d == Union[d, q[k]];
>
>  Print[d];
>
> Best regard,
>

```

• Prev by Date: Re: Re-virginating Manipulates?
• Next by Date: Re: Replacement Rule with Sqrt in denominator