I'd like to make a list of all constants that match an specific pattern, wich includes all terms that multiply an specific variable. For example, I'd like to take all terms that multiply t in:
(2 + 2 x) Cos[2 w t + 4 e^2 t/3 + ArcTan[2 x/s] + 2 t + 4 r/h^n]
matching this pattern: a*Cos[f + w t]
, and I would have:
{a,f,w}={2 + 2 x,
ArcTan[2 x/s] + 4 r/h^n,
2 w+ 4 e^2 /3+2}
I tried this:
exp = (2 + 2 x) Cos[2 w t + 4 e^2 t/3 + ArcTan[2 x/s] + 2 t] //.a_ Cos[f_ + w_ t] :> {a, f, w}
output:{2 + 2 x, 4 h^-n r + (4 e^2 t)/3 + 2 t w + ArcTan[(2 x)/s], 2}
But it didn't work, since it takes only one term... This looks to work better, but still not what I want:
exp = (2 + 2 x) Cos[2 w t + 4 e^2 t/3 + ArcTan[2 x/s] + 2 t + 4 r/h^n] //.a_ Cos[f_ + w : t*(___) ..] :> {a, f, w}
output:{2 + 2 x, 4 h^-n r + ArcTan[(2 x)/s], 2 t, (4 e^2 t)/3, 2 t w}
...{a, f, Simplify[Plus[w]/t]}...
, but it would be a horrible solution $\endgroup$