Re: Simplify[Abs[x],x<0]]
- To: mathgroup at smc.vnet.net
- Subject: [mg39323] Re: Simplify[Abs[x],x<0]]
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Tue, 11 Feb 2003 04:42:08 -0500 (EST)
- References: <b27fp8$na4$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
"Uri Zwick" <zwick at cs.tau.ac.il> wrote in message news:b27fp8$na4$1 at smc.vnet.net... > Hi, > > Simplify[ Abs[x] , x>0 ] returns x. > But, Simplify[ Abs[x] , x<0] returns Abs[x], and not -x. > > Why is that? > > Uri Uri, Mathematica considers Abs[x] to be less complex than -x: FullForm[Abs[x]] Abs[x] FullForm[-x] Times[-1, x] So we have to tell it what our measure of complexity is: Simplify[Abs[x],x<0 , ComplexityFunction->((Count[#,_Abs,Infinity])&)] -x -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565