I am trying to figure out how to pick terms proportional to $x$ (or any other expression).
I have the following problem:
I want to pick out $(1+2y) x$ from a polynomial of the form $(1+2y)x + e^xx + y^2$ (i.e., terms proportional to $x$).
I tried the command Coefficient, i.e. Coefficient[(1+2y)x + e^x x + y^2,x] x, but the output is $((1+2y)+e^x)x$. So the expression has $e^x$ in it and it is not what I am looking for.
Is there a way to pick out only the terms linear wrt $x$ from the polynomial above? I.e. constant (for x) coefficients of $x^1$
Thanks a lot.
Ps. I am only using the above polynomial as an example. In a real situation I'd expect to see polynomials with many special functions.
terms proportional to xmean? In what sense is(1+2 y)proportional tox$\endgroup$Coefficientwas returning. I've edited the question. Thanks for pointing this out. $\endgroup$Cases[Expand@expr, Longest[a_.] x /; FreeQ[a, x] :> a]works. $\endgroup$