Re: Re: Those Pesky Minus Signs
- To: mathgroup at smc.vnet.net
- Subject: [mg43334] Re: [mg43302] Re: [mg43275] Those Pesky Minus Signs
- From: Selwyn Hollis <selwynh at earthlink.net>
- Date: Mon, 25 Aug 2003 04:10:46 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Just for the record, here's a version that works much better:
pullMinus :=
HoldPattern[(c_.)*(Plus[x:Times[_?Negative,_]..])] :>
With[{r = Plus@@(-{x}[[All,1]].{x}[[All,2]])}, HoldForm[-c*r]]
5*(-a - 2*b - 3*c) /. pullMinus
-5 (a + 2 b + 3 c)
(It's also worth pointing out that the expression
Plus[x:Times[_?Negative,_]..] is spoiled when Mathematica converts it
to Input Form.)
-----
Selwyn Hollis
http://www.math.armstrong.edu/faculty/hollis
On Sunday, August 24, 2003, at 04:54 AM, Selwyn Hollis wrote:
> David,
>
> Here's a rule that may be useful:
>
> pullMinus :=
> HoldPattern[(c_.)*Plus[x:Times[_?Negative, _] ..] ] :>
> With[{r = Plus @@ {x}[[All,2]]}, HoldForm[-(c*r)]]
>
> -1/2(a + b + c)
>
> 1/2(-a - b - c)
>
> % /. pullMinus
>
> -1/2(a + b + c)
>
> -----
> Selwyn Hollis
> http://www.math.armstrong.edu/faculty/hollis
>
>
> On Saturday, August 23, 2003, at 08:09 AM, David Park wrote:
>
>> Dear MathGroup,
>>
>> How would one simplify
>>
>> (-1/2)(a + b + c)
>> 1/2(-a - b - c)
>>
>> so the minus sign was in front? Why does it get pulled within in the
>> first
>> place?
>>
>> David Park
>> djmp at earthlink.net
>> http://home.earthlink.net/~djmp/
>>
>>
>
>