Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: How to get the Real and Imaginary part of an expression
Replies: 10   Last Post: Jan 5, 2013 2:18 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bob Hanlon

Posts: 890
Registered: 10/29/11
Re: How to get the Real and Imaginary part of an expression
Posted: Jan 5, 2013 2:17 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

expr = (w = 882)/(s^2 + 2*z*w*s + w^2);

re = Re[ComplexExpand[expr, s]] //
Simplify[#, Element[z, Reals]] &;

im = Im[ComplexExpand[expr, s]] //
Simplify[#, Element[z, Reals]] &;

expr == re + I*im // FullSimplify

True

Using a concrete example

s2 = RandomComplex[] // Rationalize[#, 0] &;

re2 = re /. s -> s2 //
Simplify[#, Element[z, Reals]] &;

im2 = im /. s -> s2 //
Simplify[#, Element[z, Reals]] &;


(expr /. s -> s2) == re2 + I*im2 // Simplify

True


Bob Hanlon


On Wed, Jan 2, 2013 at 9:16 PM, Eduardo M. A. M. Mendes
<emammendes@gmail.com> wrote:
> Hello
>
> I need to extract the real and imaginary part of the following expression
>
> (w=882)/(s^2+2*z*w*s+w^2)
>
> where w and z are positive constants. s is a complex variable.
>
> Applying Re and Im to the expression does not do much. By hand, one can easily find them.
>
> What am I missing?
>
> many thanks
>
> Ed
>
>
>





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.