Suppose I have:

f[r_, ϕ_] = C1 Cos[ϕ]r + C3 Sin[3 ϕ] r + C4 Sin[4 ϕ] r^4;

How do I extract the coefficient of a chosen trigonometric term, let's say Cos[ϕ]?

  • 5
    $\begingroup$ Coefficient[f[r, \[Phi]], Cos[\[Phi]]] $\endgroup$ – Hubble07 Nov 7 '15 at 9:23
  • $\begingroup$ @Hubble07 answer? $\endgroup$ – Yves Klett Nov 21 '15 at 11:04
  • 1
    $\begingroup$ If f is meant to be an expression obtained from a computation, then the form of the expression might determine the answer. For example, Coefficient[TrigExpand@f[r, ϕ], Cos[ϕ]]. If this is an issue, FourierCoefficient might be appropriate. $\endgroup$ – Michael E2 Nov 21 '15 at 17:37

Try the following:

 Coefficient[f[r, ϕ], Cos[ϕ]]

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