MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Coefficient

  • To: mathgroup at
  • Subject: [mg126541] Re: Coefficient
  • From: Alexei Boulbitch <Alexei.Boulbitch at>
  • Date: Fri, 18 May 2012 05:24:24 -0400 (EDT)
  • Delivered-to:

Dear members,

I am using the function Coefficient[expr, form] in series such as

x(t)=a+b Cos[t]+c x[t]Cos[t]

I wonder if it is possible to force mathematica to find only the
coefficient b when using

series = a + b Cos[t] + c x[t] Cos[t]

Coefficient[series, Cos[t]]


b + c x[t]


Jesus Rico-Melgoza

Hi, Jesus,

It is not quite clear, what in general do you want to avoid. Is it that your final expression for the coefficient should not contain x[t]? If yes, I see a simple walk around.
Assume we have the the series expression slightly more general, than in your case:

series = a + b Cos[t] + c x[t] Cos[t] + d*y*Cos[t] + x[t]^2*Cos[t];

The idea is that after the complete coefficient in front of Cos[t] is obtained:

expr1 = Coefficient[series, Cos[t]]

b + d y + c x[t] + x[t]^2

one may transform it into list:

expr2 = List @@ expr1

{b, d y, c x[t], x[t]^2}

And further select only terms free of x[t]:

expr3 = Select[expr2, FreeQ[#, x[t]] &]

{b, d y}

Now one may transform it back into the sum:

Plus @@ expr3

b + d y

Now all this may be collected into a function:

coeffCos[expr_] :=
  Plus @@ Select[List @@ Coefficient[expr, Cos[t]], FreeQ[#, x[t]] &];

and check:


b + d y

If you need that the coefficient contains no functional dependence at all, the above function should be slightly modified:

coeffCos[expr_] :=
  Plus @@ Select[List @@ Coefficient[expr, Cos[t]], FreeQ[#, x_[t]] &];

Then let us check it with a more complicated expression:

series = a + b Cos[t] + c x[t] Cos[t] + d*y*Cos[t] + x[t]^2*Cos[t] +
   z[t]*Cos[t] + A[t]*x[t]*Cos[t];


b + d y

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at

  • Follow-Ups:
  • Prev by Date: Re: Partition Help
  • Next by Date: Re: unexpected behaviour of Sum
  • Previous by thread: Re: Coefficient
  • Next by thread: Re: Coefficient