Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10125

Re: Coefficient

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Coefficient
Date 2012-05-18 09:25 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jp54iv$gnd$1@smc.vnet.net> (permalink)

Show all headers | View raw


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]]


Sol

b + c x[t]


Regards


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:

coeffCos[series]

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];

coeffCos[series]

b + d y

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
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@iee.lu



Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Coefficient Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2012-05-18 09:25 +0000

csiph-web