Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

Re: Coefficient

  • To: mathgroup at smc.vnet.net
  • Subject: [mg126553] Re: Coefficient
  • From: J Jesus Rico-Melgoza <ricomelgozajjesus at gmail.com>
  • Date: Sat, 19 May 2012 05:42:07 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201205180924.FAA17091@smc.vnet.net>

Thanks for you answers

Alexei, your last suggestion works fine for want I want to do. Though, I am
still trying to understand the syntaxis of the function CoeffCos!


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


2012/5/18 Alexei Boulbitch <Alexei.Boulbitch at iee.lu>

> 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 at iee.lu
>
>


  • References:
  • Prev by Date: Re: Listplot3D and Tooltip
  • Next by Date: Re: speeding up intergration of sum
  • Previous by thread: Re: Coefficient
  • Next by thread: Maximisation question