Message Boards Message Boards

Get the Real part of a complex function with ComplexExpand and Re?

Posted 6 years ago

So I declare a complex function r[w] and I want to create another function U[w] which is defined by the real part of r[w]. So I try to use the embedded Re[] function but it returns a weird expression.

r[w]=200/(I*w*(10*I*w + 1))

If I do ComplexExpand[r[w]] I get -(2000/(1 + 100 w^2)) - (200 I)/(w (1 + 100 w^2)).

So I know that U[w] should be -(2000/(1 + 100 w^2)).

But the Re[r[w]] function returns 200 Im[1/((1 + 10 I w) w)]. Simplifying this expression by using Simplify[] and FullSimplify[] wouldn't help (even assuming that w is Real).

So how do I get the real and the imaginary part of my complex function r[w]?

Attachment

Attachments:
POSTED BY: Daniel Voloshin
3 Replies
Posted 6 years ago

This is just to illustrate, in code, Gianlucas and Murrays earlier replies:

In[1]:= r[w_] := 200/(I w (10 I w + 1))

In[2]:= t = r[q]
Out[2]= -((200 I)/((1 + 10 I q) q))

In[3]:= ComplexExpand@Re@t
Out[3]= -(2000/(1 + 100 q^2))
POSTED BY: Hans Milton

P.S. You may want your original definition to use a "patterned" variable on the left-hand side — either

 r[w_] := 200/(I w(10I w + 1))

or

 r[w_] = 200/(I w(10I w + 1))

Note also that there is utterly no need for those distracting * symbols between items of a product; just a space between symbols in a product is enough, and when the first of two items in the product is an actual number, you don't even need a space there. Almost like in printed or handwritten math! The * symbol to denote multiplication is a relic from Fortran and other programming languages as well as from early, dumb "computer-assisted algebra" systems.

POSTED BY: Murray Eisenberg

You answered yourself: ComplexExpand is made precisely for that purpose:

ComplexExpand[ReIm[r[w]]]

I don't know why Simplify does not do the job automatically in your example.

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract