Extracting Real Parts from NN Expression

• To: mathgroup at smc.vnet.net
• Subject: [mg51149] Extracting Real Parts from NN Expression
• From: carlos at colorado.edu (Carlos Felippa)
• Date: Wed, 6 Oct 2004 04:34:31 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Thank you very much to those who replied to early posts on the subject
title and help me fix several mistakes.  Finally got a robust
extraction function that has worked on a series of problems:

RealPart[c_]:=ComplexExpand[(c+Conjugate[c])/2,TargetFunctions->{Re,Im}];

I used this in expressions such as
Solve[RealPart[expr]==0,{unknowns}], in which expr is a complicated
nonnumeric complex-valued expression, to solve some stability
transition problems in C&G.  (If the real part becomes positive
stability is lost).

To see what happens with built-in Re[], a simple example is
instructive:

expr=x^2-a^2+2*I*x*y;

Print[    Solve[Re[expr]==0,x]        //InputForm];
Solve returns unevaluated

Print[    Solve[RealPart[expr]==0,x]  //InputForm];
{{x -> -a}, {x -> a}}

Note: a similar imaginary part extractor

ImagPart[c_]:=ComplexExpand[-I*(c-Conjugate[c])/2,TargetFunctions->{Re,Im}];

is still iffy, but I dont need it for my application.  It could
certainly be improved.

```

• Prev by Date: Re: Oddities of Plot[]
• Next by Date: recover a value in module at the end