Re: Coefficient Question

*To*: mathgroup at smc.vnet.net*Subject*: [mg104056] Re: Coefficient Question*From*: Bill Rowe <readnews at sbcglobal.net>*Date*: Sat, 17 Oct 2009 07:03:08 -0400 (EDT)

On 10/16/09 at 7:19 AM, sguthery at gmail.com (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? Is this acceptable to you? In[5]:= expr = 8 (3 + 5 k + 4 x1 + 6 x2 + 45 x3); expr /. {8 (3 + b_) -> 8 b} Out[6]= 8 (5 k+4 x1+6 x2+45 x3) Note, using replacement rules in this fashion isn't truly a subtraction operation. There is no mathematics being done by the replacement rule. It is up to the user to determine the mathematical validity of doing replacements like this.