Constant term in polynomial?

*Subject*: [mg3326] Constant term in polynomial?*From*: bruck at mtha.usc.edu (Ronald Bruck)*Date*: 26 Feb 1996 13:07:53 -0600*Approved*: usenet@wri.com*Distribution*: local*Newsgroups*: wri.mathgroup*Organization*: University of Southern California, Los Angeles, CA*Sender*: daemon at wri.com

Arrgh, I feel stupid asking this question, but I can't think how to do it: how do I find the constant term in a polynomial in several variables in Mathematica? For example, the "7" in 7 + 3 x y + y^2 ? I suppose one way would be to use Coefficient[Coefficient[7 + 3 x y + y^2,x,0],y,0]. But that's incredibly clunky, especially since I may have fifty or more variables in my real-life problem. I could evaluate the expression under the rule {x->0, y->0}, with the same problem: for fifty variables that's awkward. I could build the rule using Variables[expr], but that's clumsy and seems inefficient. First[7 + 3 x y + y^2] will work for this one, since the 7 is present and appears first in the FullForm representation. But it won't work in First[3 x y + y^2], which returns 3 x y. OK, so I can build a command which computes Variables[First[expr]], and if that's empty, returns 0; otherwise returns First[expr]. Also clunky IMHO, but it seems the most workable--unless there's some trap I'm missing? Or I can introduce an auxiliary variable "one", refer to the polynomial as "7 one + 3 x y + y^2", and ask for Coefficient[expr, one]. Gag! If I ever want to EVALUATE it, I have to remember to use the rule one->1. There MUST be a standard way to do this, but I can't think of what it could be! --Ron Bruck