Message Boards Message Boards

Problem taking Real part of expression involving a variable

Posted 9 years ago

This should be simple fix but I am stuck. I am attempting to take the real part of an extensive complex number involving a variable. I was able to make it work with my first expression (delta1) but the same method fails with my second expression (delta2). I don't understand why it would work for one and not the other. Any help would be much appreciated!

Here's my code:

k1 = 2;
k2 = 2;
k12 = 2;
m1 = 1;
m2 = 1;
f = 1;
b = .1;
M = {{m1, 0}, {0, m2}};
K1 = {{k1 + k12, -k12}, {-k12, k2 + k12}};
a = {a1, a2};
F0 = {f, f};
B = {b, b};
Solve[Det[K1 - \[Omega]^2*M] == 0];
Sol = LinearSolve[(K1 + I*B*\[Omega] - \[Omega]^2*M), F0];
C1 = Sol[[1]];
C2 = Sol[[2]];


\[Delta]1 = 
 Simplify[Im[ComplexExpand[C1]], Element[\[Omega], Reals]]/
  Simplify[Re[ComplexExpand[C1]], Element[\[Omega], Reals]]
\[Delta]2 = 
 Simplify[Im[ComplexExpand[C1]], Element[\[Omega], Reals]]/
       Simplify[Re[ComplexExpand[C1]], Element[\[Omega], Reals]]
Attachments:
POSTED BY: John Baker
5 Replies
Posted 9 years ago

I think I actually found the correct way to do this. Instead of taking the real part of complex expand, I needed to switch the operations and take the real part of C1 and then perform complex expand on that section. Complex expand expands the expression under the assumption that all non-numeric quantities are real. Seems to work now.

Thanks for all the input!

TL/DR Instead of:

Re[ComplexExpand[C1]]

This:

ComplexExpand[Re[C1]]
POSTED BY: John Baker

Things are not as easy as I thought. In the Help-Section you are informed as

"Im[expr] is left unevaluated if expr is not a numeric quantity."

So with your C1 from above try the following statements :

C1
Print["A1"]
A1 = Chop[C1]
Print["A2"]
A2 = ComplexExpand[A1]
Print["A3"]
A3 = A2 /. x_ + Complex[0, 1]*y_ -> Complex[x, y]
Print["A4"]
A4 = A3[[2]]
Print["A5"]
A5 = A2 /. x_ + I y_ -> y
POSTED BY: Hans Dolhaine

Hmmm, things seem to be complicated. Knowing that omega is real try

Simplify[Im[Chop[ComplexExpand[C1]]]]
% /. Im[_] -> 0 /. Re[x_] -> x
POSTED BY: Hans Dolhaine

Mathematica doesn't know anything about omega.

In[54]:= Im[a + b I]

Out[54]= Im[a] + Re[b]

But

In[55]:= Simplify[Im[a + b I], Element[{a, b}, Reals]]

Out[55]= b
POSTED BY: Hans Dolhaine

Make the b = 1/10 an exact number (otherwise b is the only approximate number and there are terms like 0. + ...) and it works

In[43]:= \[Delta]1 = 
 Simplify[Im[ComplexExpand[C1]], Element[\[Omega], Reals]]/
  Simplify[Re[ComplexExpand[C1]], Element[\[Omega], Reals]]

Out[43]= (\[Omega] (100 - 99 \[Omega]^2 + 25 \[Omega]^4))/(5 (-2 + \[Omega]^2) (\[Omega]^2 + 
   25 (-2 + \[Omega]^2)^2))

In[44]:= \[Delta]2 = 
 Assuming[\[Omega] \[Element] Reals, 
  Simplify[Refine[Re[ComplexExpand[C2]], Element[\[Omega], Reals]], 
   Element[\[Omega], Reals]]]


Out[44]= -((25 (-2 + \[Omega]^2))/(100 - 99 \[Omega]^2 + 25 \[Omega]^4))
POSTED BY: Udo Krause
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