Re: Those Pesky Minus Signs
- To: mathgroup at smc.vnet.net
- Subject: [mg43349] Re: Those Pesky Minus Signs
- From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
- Date: Tue, 26 Aug 2003 07:13:22 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
David Park wanted to fix it so that (-1/2)(a+b+c) wouldn't return (1/2)(-a-b-c) I don't know why it works that way, but the following definitions will fix the problem. The second definition puts the minus sign in the numerator of a rational number. --------------------------- MakeBoxes(a_*b:Plus[_?Negative*_, (_?Negative*_)..], form:(StandardForm|TraditionalForm)]:= RowBox[{MakeBoxes@@{-a,form}, RowBox[{"(", MakeBoxes@@{-b, form}, ")"}] }] MakeBoxes[p_Rational?Negative, form:(StandardForm|TraditionalForm) ]:= FractionBox[ MakeBoxes@@{Numerator[p],form}, MakeBoxes@@{Denominator[p],form} ] ----------------------------- This fixes situations you didn't address. Now (-1/2)(a+2.3 b+c) returns itself. ---------------------------- Regards, Ted Ersek Get Mathematica tips, tricks from http://www.verbeia.com/mathematica/tips/Tricks.html