Re: Coefficient[ ] quirks

*To*: mathgroup at smc.vnet.net*Subject*: [mg93326] Re: [mg93310] Coefficient[ ] quirks*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>*Date*: Tue, 4 Nov 2008 06:16:05 -0500 (EST)*References*: <200811031028.FAA05229@smc.vnet.net>

On 3 Nov 2008, at 19:28, AES wrote: > If you have a function f = a + b (z-c)^2 and want to extract out the > powers of the "form" (z-c), you can use either Coefficient[f, (z-c), > n] > or Coefficient[f, (z-c)^2, n]. The first one gives you {a, 0, b} for > the first three coefficients, while the second one gives you {a, b, > 0}, > both of these of course being entirely correct. > > Suppose however that you add a denominator to the function, e.g. > f = (a + b (z-c)^2 )/d. Then the first approach (looking for powers > of > (z-c)) no longer gives you the information you're seeking, but instead > stuffs the entire f into the first position, i.e. {f, 0, 0} -- which > at > least doesn't throw away any information about f. > > The second approach (looking for powers of (z-c)^2) still works fine > even with a denominator added, however, and gives you {a/d, b/d, 0}. > > If out of restless curiosity, you then expand out the square of (z-c) > into either of the forms f = (a + b (z^2 - 2 c z + c^2) or > f = (a + b z^2 - 2 b c z + + b c^2), with or without the denominator, > but still seek powers of (z-c) (which are no longer explicitly > present), > the first approach continues to give you {f, 0, 0}, which it can be > argued is entirely correct, since there is no longer any explicit > power > of (z-c) in f. > > The second approach, however, now gives you either {a, 0, 0} or {a/ > d, 0, > 0}, which in a certain sense is arguably correct for the first or n=0 > term -- any powers of z or c have apparently been chopped off, even > though you asked Coefficient to look only for powers of (z-c). > > The only problem is that they seem to have been thrown out totally, > beyond recovery. You could write > > f = Sum[Coefficient[f, (z-c), n] * (z-c)^n, {n,0,Infinity}] > > for f with or without denominator, and never get all your function > back. > > It all seems rather quirky . . . > Because it is not the way to do this at all... There are a number possible approaches but only one that is completely reliable (and very standard in this sort of situation, not just in Mathematica) is : f = (a + b (z^2 - 2 c z + c^2)) SeriesCoefficient[f + O[z, c]^10, 2] b This will work no matter how you express your f. Andrzej Kozlowski

**References**:**Coefficient[ ] quirks***From:*AES <siegman@stanford.edu>

**Trouble solving system of first order, two variable PDEs in**

**Re: 3D Graphics in a Palette or Dialog**

**Coefficient[ ] quirks**

**Re: Coefficient[ ] quirks**