       Re: assumption, supposition?

• To: mathgroup at smc.vnet.net
• Subject: [mg15351] Re: assumption, supposition?
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Sat, 9 Jan 1999 23:58:15 -0500
• References: <774kr1\$46h@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Erk Jensen wrote in message <774kr1\$46h at smc.vnet.net>...
>Probably I'm looking up the wrong keyword in Mathematica help, but I
>can't find what I'm looking for. Maybe that's because I've learned
>those expressions in german...
>
>My problem:
>
>I want Mathematica to assume that a certain condition is satisfied for
>the following algebraic transformations. More specifically: Let rho
>describe a radius coordinate. I know it is not negative real. So, for
>transformations of expressions containing rho, e.g.  Sqrt[rho^2], I
>want assure Mathematica that 0 <= rho is in fact satisfied, and that it
>is consequently allowed to replace Sqrt[rho^2] by rho. How do I do
>that?
>
>My solution was
>
>Unprotect[Sqrt]; Sqrt[rho_^2] := rho/; 0 <= rho; Protect[Sqrt];
>
>rho /: 0 <= rho = True;
>
>and this seems to work, but I wonder whether this is really the proper
>way. Since the TagSet I'm using here assigns the whole statement to
>rho, and ?rho results in
>
>Global`rho
>rho /: 0 <= rho = True
>
>so I still have my doubts ...
>
>Can some of you experts enlighten me?
>
>               -erk-
>

Erik:

This looks OK:

The definition

Unprotect[Sqrt];
Sqrt[(rho_)^2] := rho /; 0 <= rho;
Protect[Sqrt];

is not restricted to rho (which here is a dummy variable). We can use

c/: c<=0 = True;

and get

Sqrt[c^2]

c

Unfortunately Mathematica does not do any deduction:

d/: (d>=0)=True;

Sqrt[d^2]

Sqrt[d^2]

But we can allow for this by

Unprotect[Sqrt];
Sqrt[(rho_)^2] := rho /; 0 <= rho
Protect[Sqrt];

Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

```

• Prev by Date: Re: setting X and Y range in 2D plots
• Next by Date: Re: setting X and Y range in 2D plots
• Previous by thread: Re: assumption, supposition?
• Next by thread: Re: assumption, supposition?