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/
- References:
- defining variables as Real
- From: "symbio" <symbio@has.com>
- defining variables as Real