MathGroup Archive 2004

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

Search the Archive

Re: defining variables as Real

  • To: mathgroup at smc.vnet.net
  • Subject: [mg52827] Re: [mg52778] defining variables as Real
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Tue, 14 Dec 2004 05:59:19 -0500 (EST)
  • References: <200412130922.EAA23381@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 13 Dec 2004, at 18:22, symbio wrote:

> *This message was transferred with a trial version of CommuniGate(tm) 
> Pro*
> Is there anyway in Mathematica to define a variable as say Real or 
> Imaginary
> or greater than zero, etc.. in the very beginning of all calculations 
> and
> keep it that way throughout, instead of having to use simplify with
> assumptions each time?
>
>

Well, there is, but you may still not like it ;-)

One way is to use $Pre:


$Pre = Simplify[#1, a > 0] & ;


Sqrt[a^2]

a

There are two problems with that. One is that Simplify will now be used 
on every expression, which will casue a general slowdown in all your 
computations and may even prevent you form getting your results in the 
form you want. Secondly, sometimes SImplify will not be enough and you 
may stil need to apply FullSimplify. You can partially solve the first 
problem  by usinga definition like:


$Pre = If[ !FreeQ[#1, a], Refine[#1, a > 0], #1] & ;


Sqrt[a^2]


a

Refine uses a lot fewer rules than Simplify so it will take less time, 
but on the other hand it will often not be strong enough for what you 
want and you may end up applying Simplify anyway.

I am pretty sure the same problems will be found with any other 
solution to this issue.




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


  • Prev by Date: Re: Re: Newbie Question -- Plot3d::plnc
  • Next by Date: Re: Re: How to evaluate Exp[I Pi(1+x)]?
  • Previous by thread: defining variables as Real
  • Next by thread: Re: defining variables as Real