       Re: Question on Positive[x]=True

• To: mathgroup at smc.vnet.net
• Subject: [mg7946] Re: Question on Positive[x]=True
• From: Dick Zacher <dick at loc3.tandem.com>
• Date: Fri, 25 Jul 1997 02:40:22 -0400
• Organization: Tandem Computers
• Sender: owner-wri-mathgroup at wolfram.com

```Raya Firsov-Khanin <raya at mech.ed.ac.uk> wrote:

> I have the following question.  I want to state that a variable
> x is positive. On page 1170 of the Third edition of The Mathematica
book
> it is said that I can do it by making a definition
>
>     Positive[x] = True
>
> However, while trying to do it I get a message :
>
> Set::write: Tag Positive in Positive[x] is Protected
>
> Any suggestions on how one can make variables positive, negative
etc?

I have seen several postings in response to Raya's query, but none of
them mentions this crucial point: To specify that a variable is
positive, it is far more useful to specify an upvalue for Sign than for
Positive. The reason is that Positive tests the value of Sign for the
variable, but the reverse is not true. If you set upvalues for Sign,
then you will automatically get correct results for both Positive and
Negative -- not only when you test the variables themselves, but also
when you test products, quotients, and integral powers of the variables.
You don't have to write special rules to handle these cases. Some
examples:

In:=
\$Version

Out=
"Solaris 3.0 (November 22, 1996)"

In:=
Sign[a] ^= 1;
Sign[b] ^= 1;
Sign[q] ^= -1;
Sign[r] ^= -1;

In:=
{Positive[a],Negative[a],Positive[q],Negative[q]}

Out=
{True,False,False,True}

In:=
{Positive[a*b],Positive[q*r],Negative[a/q],Negative[q^-3]}

Out=
{True,True,True,True}

In:=
{Negative[a*x],Positive[q*x]}

Out=
{Negative[x],Positive[-x]}

--
-----------------------------
Dick Zacher
Performance Engineering Dept., Tandem Computers
zacher_dick at tandem.com     phone: 408-285-5746     fax:   408-285-7079

```

• Prev by Date: [Q]contour integral in MMA3.0
• Next by Date: Minima
• Previous by thread: Re: Question on Positive[x]=True
• Next by thread: Q: Help on Plotting with Mathematica