MathGroup Archive 2009

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

Search the Archive

Re: Coefficient Question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104051] Re: Coefficient Question
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sat, 17 Oct 2009 07:02:13 -0400 (EDT)
  • References: <200910161119.HAA01303@smc.vnet.net>

On 16 Oct 2009, at 20:19, Scott 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
>

Well, you could always do:

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

First[CoefficientArrays[f, Variables[f]]]

24

Though actually whether that is actually in any sense "easier" than

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

  24

seems doubtful to me.

Andrzej Kozlowski



  • Prev by Date: Re: Coefficient Question
  • Next by Date: Re: Code folding and wrapping using the input->code method?
  • Previous by thread: Coefficient Question
  • Next by thread: Re: Coefficient Question