Re: How to force Mathematica to treat a number as positive and real?
- To: mathgroup at smc.vnet.net
- Subject: [mg51880] Re: [mg51831] How to force Mathematica to treat a number as positive and real?
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 4 Nov 2004 01:49:38 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
Clear[a];
a /: Abs[a]=a;
Abs[a]
a
However, trying to specify all desired results with upvalues (TagSet) can easily
lead to recursion problems. It is easier to just use an assumption with
Simplify or FullSimplify.
Clear[a];
Simplify[
{Re[a], Im[a], Abs[a], a>0, a<0, Sqrt[a^2]},
a>0]
{a,0,a,True,False,a}
Bob Hanlon
>
> From: wilhelm.rainer at gmx.net (Rainer)
To: mathgroup at smc.vnet.net
> Date: 2004/11/03 Wed AM 01:24:18 EST
> To: mathgroup at smc.vnet.net
> Subject: [mg51880] [mg51831] How to force Mathematica to treat a number as positive
and real?
>
> I'd like to do some symbolic computation with parameters. These
> parameters (named, e.g. "a") are always *real-valued* and positive. I
> managed to tell Mathematica that a is a real number by using:
>
> a/:Im[a]=0;
>
> This works since the response to "Re[a]" is now "a" (and not "Re[a]"
> which is the general result when one does not use the above definition
> of a).
>
> Now, I would like to do a similar thing, forcing Mathematica to assume
> that a is a positive number. I want that the result of Abs[a] is equal
> to a. I tried:
>
> a/:Positive[a]=True;
>
> but it does not work. Does anybody know how I can do this?
> Thanks
> Rainer
>
>