2
$\begingroup$

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[ϕ]?

$\endgroup$
3
  • 6
    $\begingroup$ Coefficient[f[r, \[Phi]], Cos[\[Phi]]] $\endgroup$
    – Hubble07
    Commented Nov 7, 2015 at 9:23
  • $\begingroup$ @Hubble07 answer? $\endgroup$
    – Yves Klett
    Commented Nov 21, 2015 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
    Commented Nov 21, 2015 at 17:37

1 Answer 1

6
$\begingroup$

Try the following:

 Coefficient[f[r, ϕ], Cos[ϕ]]
$\endgroup$

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