MathGroup Archive 2004

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

Search the Archive

Extracting Real Parts from NN Expression


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
  • Previous by thread: Re: Reads in only part of file
  • Next by thread: Re: Extracting Real Parts from NN Expression