MathGroup Archive 2004

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

Search the Archive

Re: How to force Mathematica to treat a number as positive and real?


On 3 Nov 2004, at 15:24, Rainer wrote:

> 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
>
>
Assuming you have Mathematica 5.0 you should use Refine and the 
Assumptions mechanism. You can even do it in a "global" way, as folows:

This tells Mathematica to Refine every statement using the current 
assumptions:

$Pre = Refine[#] &;

Next, define the assumptions:

$Assumptions = {a ³ 0};

Now


Abs[a]

a


Andrzej Kozlowski
Chiba, Japan
http://www.akikoz.net/~andrzej/
http://www.mimuw.edu.pl/~akoz/


  • Prev by Date: Re: Re: Null entry in a Graphics list?
  • Next by Date: Re: How to force Mathematica to treat a number as positive and real?
  • Previous by thread: How to force Mathematica to treat a number as positive and real?
  • Next by thread: Re: How to force Mathematica to treat a number as positive and real?