Re: A way around the limitations of Re[] and Im[]

*To*: mathgroup at smc.vnet.net*Subject*: [mg51136] Re: A way around the limitations of Re[] and Im[]*From*: pein <petsie at arcor.de>*Date*: Wed, 6 Oct 2004 04:34:08 -0400 (EDT)*References*: <cjr8lg$opp$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Carlos Felippa schrieb: > As you know, Re[expr] and Im[expr] are left unevaluated when expr is > not numeric. I had good luck in simple cases with the following > substitution trick: > > Real[c_]:=c/.I->0; Imag[c_]:=(c-Real[c])/.I->1; > > Do you see any problem with these definitions? > Yes. The very simple example Sqrt[a] fails with your definitions. ComplexExpand[Sqrt[a], TargetFunctions -> {Re, Im}] gives a correct result. -- Peter Pein, Berlin