Re: rules for Sign[_]^n

*To*: mathgroup at smc.vnet.net*Subject*: [mg26353] Re: [mg26337] rules for Sign[_]^n*From*: Andrzej Kozlowski <andrzej at bekkoame.ne.jp>*Date*: Wed, 13 Dec 2000 02:41:15 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

on 12/12/00 4:54 PM, Adalbert Hanssen at hanssen at Zeiss.de wrote: > Hi, MathGroup, > > dealing with Sign, it would be useful, if Mathematica > knew > > {(Sign[_])^(y_?EvenQ):>1, (Sign[x_])^(y_?OddQ):>Sign[x]} > > How can I teach Mathematica this rule (in Init.m), such that it > automaticly applies it in Simplify, Expand and the like > whenever applicable? > > kind regards > > Dipl.-Math. Adalbert Hanszen > In fact it is easy enough to do: In[1]:= Unprotect[Sign]; In[2]:= Sign /: Sign[_]^x_?EvenQ = 1; Sign /: Sign[y_]^x_?OddQ = Sign[y]; In[3]:= Protect[Sign]; Now: In[4]:= Sign[x^4*y^3] Out[4]= Sign[y] and so on. Note however that this contradicts the built-in meaning of Sign in Mathematica in certain special cases. In Mathematica Sign[0] is 0 (and Sign[I] is I). So you can now produce contradictions like: In[5]:= ( Sign[x] - x)^2 /. x -> 0 Out[5]= 0 In[6]:= Expand[( Sign[x] - x)^2] /. x -> 0 Out[6]= 1 Note also that even without these definitions Mathemtica will (almost) correctly apply rules for Sign in Simplify: (Fresh Kernel session) In[1]:= Simplify[Sign[x]^12, Element[x, Reals] && x ? 0] Out[1]= 1 In[2]:= Simplify[Sign[x]^13, Element[x, Reals] && x ? 0] Out[2]= 13 Sign[x] This last output seems a bit unfortunate and probably ought to be corrected in a future version. Still: In[3]:= Simplify[Sign[x]^13, x > 0] Out[3]= 1 In[4]:= Simplify[Sign[x]^13, x < 0] Out[4]= -1 are fine. -- Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/ http://sigma.tuins.ac.jp/