Re: Coefficient[ ] quirks

*To*: mathgroup at smc.vnet.net*Subject*: [mg93331] Re: [mg93310] Coefficient[ ] quirks*From*: Daniel Lichtblau <danl at wolfram.com>*Date*: Tue, 4 Nov 2008 06:17:01 -0500 (EST)*References*: <200811031028.FAA05229@smc.vnet.net>

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. Right. It's a bug of sorts, but not the most serious since it involves functionality not too far removed from voodoo. It will be fixed (whether it will then be unfixed due to having created worse problems is anyone's guess). > 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). This is also a bug in the flow-of-creative-semantics. Will be fixed subject to same caveat as above. > 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 . . . It is. Anything that uses "variables" that are not in some sense "obviously" variables, is going to encounter some rough edges. (Which edges? All of them.) Daniel Lichtblau Wolfram Research

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

**Re: Frustration with opaque functions in Mathematica**

**Re: Coefficient[ ] quirks**

**Re: Coefficient[ ] quirks**

**Re: Coefficient[ ] quirks**