MathGroup Archive 2009

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

Search the Archive

Re: Coefficient Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104047] Re: Coefficient Question
  • From: "David Park" <djmpark at comcast.net>
  • Date: Sat, 17 Oct 2009 07:01:29 -0400 (EDT)
  • References: <21621663.1255691321479.JavaMail.root@n11>

poly = 8 (3 + 5 k + 4 x1 + 6 x2 + 45 x3);

Select[Expand[poly], FreeQ[#, Alternatives @@ Variables[poly]] &]
24

Extract[CoefficientList[poly, Variables[poly]], 
 Array[1 &, Length[Variables[poly]]]]
24

Array[0 &, Length[Variables[poly]]] /. 
 CoefficientRules[poly, Variables[poly]]
24


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: Scott [mailto:sguthery at gmail.com] 

I've got the expression

8(3+5k+4x1+6x2+45x3)

and I want to extract the constant 24.

Yes, I can define a function and then set k and x1 and x2 and x3 to 0
but there has to be easier way, no?

Any suggestions?

Thanks much.

Cheers, Scott




  • Prev by Date: Re: Coefficient Question
  • Next by Date: Re: Subscript[x,1] value do not get cleared using Clear["Global`*"] but get removed using Remove["Global`*]
  • Previous by thread: Re: Coefficient Question
  • Next by thread: WorkingPrecision and NDSolve