I want to extract coefficients of a linear formula and I wrote the following function. But it didn't work.
f = Subscript[x, 1] + Times[2, Subscript[x, 2]]
extractCoeff[f_] := Table[If[Head[f[[i]]] == Times, f[[i, 1]], 1], {i, Length[f]}]
What should I do?
Please tell me.
SameQ(===);Equal(==) is not intended for the comparison you want to do. – J. M.'s missing motivation Oct 02 '18 at 11:15