MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: rules for Sign[_]^n

  • To: mathgroup at
  • Subject: [mg26355] RE: [mg26337] rules for Sign[_]^n
  • From: "Ingolf Dahl" <f9aid at>
  • Date: Wed, 13 Dec 2000 02:41:16 -0500 (EST)
  • Sender: owner-wri-mathgroup at

I would recommend that you add Real to the specification of your variables,
otherwise you might get problems with complex numbers:

{(Sign[_Real])^(y_?EvenQ) :> 1, (Sign[x_Real])^(y_?OddQ) :> Sign[x]}

You know, Sign[I]^2 == -1.

This works if you apply the rule to numbers, which is not very useful, since
you then are able to calculate Sign anyway. Probably you want to apply the
rules to symbolic variables that are known to be real, and then the above
approach will not work. In that case, you can define z to be real by

z /: Im[z] = 0;
(see Help for Add-on Standard Package Algebra`ReIm`, but this package does
not seem to be necessary)

Then the following rule seems to work

{(Sign[x_ /; Im[x] == 0])^(y_?EvenQ) :>
    1, (Sign[x_ /; Im[x] == 0])^(y_?OddQ) :> Sign[x]}

If you want to teach Mathematica to apply this rule, you have to modify

Power[Sign[x_ /; Im[x] == 0], y_?EvenQ] := 1;
Power[Sign[x_ /; Im[x] == 0], y_?OddQ] := Sign[x];

Maybe the package Algebra`ReIm` could be useful for you, check the help.

I hope that I have got everything right

Kind regards

Ingolf Dahl
Chalmers University

> Adalbert Hanssen [hanssen at] wrote in  [mg26337] rules for
Hi, MathGroup,

dealing with Sign, it would be useful, if Mathematica

{(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

  • Prev by Date: Re: BarChart, Bar Labels disappear
  • Next by Date: Re: sum of the angle in a 4th dim triangle
  • Previous by thread: rules for Sign[_]^n
  • Next by thread: Re: rules for Sign[_]^n