Here is the expression.
I want to extract the coefficient just as the table showing below.
I can do it by hand, but I expect a code that can automatically identify how many differenct terms there are ,what is its coefficient and show them all in a table.
this is the expression for Mma.
expr= (3 Subscript[1, b] Subscript[2, a])/8+1/8 E^(I [Theta]) Subscript[1, b] Subscript[2, a]+1/8 E^(2 I [Theta]) Subscript[1, b] Subscript[2, a]+3/8 E^(3 I [Theta]) Subscript[1, b] Subscript[2, a]-(3 Subscript[1, a] Subscript[2, b])/8+1/8 E^(I [Theta]) Subscript[1, a] Subscript[2, b]-1/8 E^(2 I [Theta]) Subscript[1, a] Subscript[2, b]+3/8 E^(3 I [Theta]) Subscript[1, a] Subscript[2, b]-(Sqrt[3] Subscript[3, a])/8-1/8 Sqrt[3] E^(I [Theta]) Subscript[3, a]+1/8 Sqrt[3] E^(2 I [Theta]) Subscript[3, a]+1/8 Sqrt[3] E^(3 I [Theta]) Subscript[3, a]+(Sqrt[3] Subscript[3, b])/8-1/8 Sqrt[3] E^(I [Theta]) Subscript[3, b]-1/8 Sqrt[3] E^(2 I [Theta]) Subscript[3, b]+1/8 Sqrt[3] E^(3 I [Theta]) Subscript[3, b]
I think of a example as below:
tab[expr_] := {#,
Coefficient[
expr, #]} & /@ (expr //
List @@ # & // # /. {Power[_, _] -> 1, Rational[_, _] -> 1,
E -> 1} & // Union) // Grid[#, Frame -> All] &
so, expr//tab
will get the table above.
Coefficient
. $\endgroup$ – Spawn1701D Apr 25 '13 at 11:25tab
, here's another approach, maybe it helps? Voilà:Grid[Transpose@{#, Coefficient[expr, #]} &@Union[Cases[expr, Times[c___ : 1, a : _Subscript, b :___Subscript] :> a b, 2]],Frame -> All]
$\endgroup$ – Pinguin Dirk Apr 25 '13 at 12:04