Re: How to isolate the constant in a two variable
- To: mathgroup at smc.vnet.net
- Subject: [mg113482] Re: How to isolate the constant in a two variable
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sat, 30 Oct 2010 04:39:06 -0400 (EDT)
expr = 4 X*X + 3 Y*Y + 2 X*Y + 1; If there is always a constant expr[[1]] 1 But note that if there is no constant then (expr - 1)[[1]] 4 X^2 Fix with Module[{c = expr[[1]]}, If[NumericQ[c], c, 0]] 1 The following are more robust Select[expr, NumericQ] 1 Using Coefficient Fold[Coefficient[#1, #2, 0] &, expr, Variables[expr]] 1 Using coefficientList Module[{vars = Variables[expr]}, CoefficientList[expr, vars][[Sequence @@ Table[1, {Length[vars]}]]]] 1 Bob Hanlon ---- "Eduardo M. A. M.Mendes" <emammendes at gmail.com> wrote: ============= Hello I know that Coefficient can isolate the coefficient relate to the variables in an equation but I wonder how the constant could be retrieved. Something like 4X*X+3Y*Y+2X*Y+1 How to get to isolate the constant 1? Many thanks Ed