Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Coefficient Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104065] Re: Coefficient Question
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 17 Oct 2009 07:04:49 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

Here are a few

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

expr // Expand // First

24

expr /. Thread[Variables[expr] -> 0]

24

DeleteCases[expr // Expand, _*_Symbol]

24

Cases[expr // Expand, _?NumericQ] // First

24

CoefficientList[expr, Variables[expr]] // Flatten // First

24


Bob Hanlon

---- Scott <sguthery at gmail.com> wrote: 

=============
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: Coefficient Question
  • Previous by thread: Re: Coefficient Question
  • Next by thread: Re: Coefficient Question