2
$\begingroup$

consider following expression:

t = Subscript[α, 0]/2 + Subscript[α, 1]/2 + 2 Subscript[α, 2] + (9 Subscript[α, 3])/2 + 
8 Subscript[α, 4] + (25 Subscript[α, 5])/2 + 18 Subscript[α, 6] + (49 Subscript[α, 7])/2 + 
32 Subscript[α, 8] + (81 Subscript[α, 9])/2;

one can access variable list of expression above by using:

Variables[t]

but how can I get the corresponding coefficient list of variables? I've tried:

CoefficientList[t, Variables[t]]

it just doesn't work...

$\endgroup$
1
  • $\begingroup$ Try CoefficientArrays. $\endgroup$
    – Szabolcs
    May 27, 2014 at 21:14

1 Answer 1

4
$\begingroup$

The problem with:

CoefficientList[t, Variables[t]]

is that it appears to create a matrix with all the cross terms. Since you only want to first order terms, try out:

Coefficient[t, Variables[t], 1]
{1/2, 1/2, 2, 9/2, 8, 25/2, 18, 49/2, 32, 81/2}

instead.

$\endgroup$
1
  • 2
    $\begingroup$ 1 seems to be redundant. $\endgroup$
    – Kuba
    May 27, 2014 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.