Re: Extracting Re and Im parts of a symbolic expression
- To: mathgroup at smc.vnet.net
- Subject: [mg42123] Re: Extracting Re and Im parts of a symbolic expression
- From: carlos at colorado.edu (Carlos Felippa)
- Date: Thu, 19 Jun 2003 04:00:31 -0400 (EDT)
- References: <bcmodv$sm8$1@smc.vnet.net> <bcp0g1$7qr$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
AES/newspost <siegman at stanford.edu> wrote in message news:<bcp0g1$7qr$1 at smc.vnet.net>... > In article <bcmodv$sm8$1 at smc.vnet.net>, > Andrzej Kozlowski <akoz at mimuw.edu.pl> wrote: > > > Note that CompelxExpand[Re[z]] works, Re[ComplexExpand[z]] is pointless > > since it is just Re[z]. > > And the reason why this question keeps coming up year after year on this > newsgroup (and why I have to look up the answer in my own online "Mathematica > Notes" notebook almost every time I use this construct) is that the > intuitive way any normal user would write an expression to get the real > part of an expression is > > Re[ComplexExpand[expr]] > > whereas the "correct" Mathematica statement > > ComplexExpand[Re[expr]] > > is under any normal interpretation an absurd way of expressing what the > user wants. > > [In real life compound expressions almost expand **from the inside > out**: If you want the log of the sin of z you write Log[Sin[z]]. So, > the second expression above says you're going to take the REAL part of > expr, and then COMPLEX-EXPAND the result, even though the result is > something that's already explicitly real, right? > > Don't both explaining again **why** it works this way -- my only point > is that maybe in a larger picture of the logical design of Mathematica > syntax it has to be structured this way, but unfortunately it's an > intrinsically confusing way of expressing the user's objective, and > always will be.] The underlying problem is the lack of variable typing, as well as assumptions (aka constraints), stored in a global database. E.g. Declare[x,Real,{x>0,x=<5}] Some of this essential need has filtered over time into two functions: Integrate and Simplify, as optional declarations although they use different notation. On exit from either whatever was declared is lost, leading to inconsistencies. ComplexExpand displays a third, "implicit assumption" form: ComplexExpand[x+I*y] assumes x and y are real. As in the explicit forms noted above, the information is lost. So Re[ComplexExpand[x+I*y]] or Abs[ComplexExpand[x+I*y]] cannot possibly work because the assumptions go out of scope.