MathGroup Archive 1990

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

Search the Archive

Re: Coefficient

  • To: mathgroup at yoda.ncsa.uiuc.edu
  • Subject: Re: Coefficient
  • From: CAMERON at midd.cc.middlebury.edu
  • Date: Tue, 11 Dec 90 11:21:35 -0600

I mailed this response privately to the original poster,
Keith Slavin (keith at videovax.tv.tek.com), but since then
I have seen so many other comments posted to MathGroup that
I thought perhaps I should broadcast this as well as sending
it privately, because I haven't seen anyone else mention
this approach.

The original question:

> I seem to be having a problem with the behaviour of Coefficient[] in
> Mathematica, namely if I have a series such as
>
> sum = ... + a n + b + c/n +....
>
> then Coefficient[sum,n] gives a, Coefficient[sum,1/n] gives c, but
> Coefficient[sum,1] does NOT give b, but zero instead! This is causing me
> problems, and I cannot see a simple work-around.

Well, it seems to me that Coefficient[sum,1] can't know to
give you "b" instead of "0" in "sum", because how does it know
that you are interested in powers of "n" rather than (say)
powers of "b"?

It's already been pointed out that Coefficient[sum,n,0] doesn't
work right for the given "sum" because of the negative powers of
n.  (Personal opinion: I don't regard as satisfactory any solution
that has this constraint.)

Mathematica's "FreeQ" is useful here... try "Select[sum,FreeQ[#,n]&]".
That gives you just the terms of "sum" that don't have an "n"
in them, which presumably is the "coefficient of 1" in a series
in the variable "n"?  It works if "sum" is actually an expression
of the form "Plus[ ... , .... ]".  Of course you referred to the
value of "sum" as a "series", and the "FreeQ" approach will *not*
work if the value of "sum" actually is a "SeriesData" object (as
produced by Mma's "Series" operator).  In that case, you could
use "Normal" to convert the "SeriesData" object to a "Plus" object.

Hope this helps--
--Cameron Smith
  Mathematica consultant
  CAMERON at MIDD.BITNET  --or--  cameron at midd.cc.middlebury.edu


  • Prev by Date: Coefficient[]
  • Next by Date: Power[] corrupts, Absolute[Power[]] corrupts absolutely
  • Previous by thread: Coefficient
  • Next by thread: D and sinh'; s/c vs. s*c^(-1).