# Imaginary part of complex number, nothing works?

I want to find the imaginary part of the complex number (a+i*b).

say I have a function in the following form:

((-2 + 4 I) Cos[0.0628319 z] + (2 - I) Sin[0.0628319 z])/
((1 + 2 I) Cos[0.0628319 z] + (4 + 2 I) Sin[0.0628319 z])


where $z$ is a real number variable. I want to reform the function into (a+i*b) form.

attempt:

if I do Im, then it wil give me the following output:

Im[((-2 + 4 I) Cos[0.0628319 z] + (2 - I) Sin[
0.0628319 z])/((1 + 2 I) Cos[0.0628319 z] + (4 + 2 I) Sin[
0.0628319 z])]


but this is not what I want.

• Consider tugging // ComplexExpand // Simplify on the end. Jan 31 '16 at 21:53
• If you know that z is a real number, then do ComplexExpand[Im[ ... ]]. Jan 31 '16 at 21:53

func[z_] := ((-2 + 4 I) Cos[0.0628319 z] + (2 - I) Sin[
0.0628319 z])/((1 + 2 I) Cos[0.0628319 z] + (4 + 2 I) Sin[
0.0628319 z])
ComplexExpand@func[0]
Show[
Plot[
Im@func[z],
{z, 0, 100}, PlotStyle -> Blue
],
Plot[
Re@func[z],
{z, 0, 100}, PlotStyle -> Red
], PlotRange -> All
]

(*1.2 + 1.6 I*)


You're not tryng to get the imaginary part of a number. You are trying to get the imaginary part of an expression. Let's say we define your expression to be equivalent to eq:

eq==(2 + 4 I) Cos[0.0628319 z] + (2 - I) Sin[0.0628319 z])/
((1 + 2 I) Cos[0.0628319 z] + (4 + 2 I) Sin[0.0628319 z])


Solving the above for z gives 4 solutions. Lets say we take one of them and try a full simplify on it. We would get a fraction whose denominator has a real and an imaginary part. (I'm working via the cloud so I'll paste the result as InputForm:

ArcCos[((5.322525763080274 -
9.01827480722634*I) -
(20.816270607258474 - 2.3058885477431663*I)*eq)/
Sqrt[(159. + 288.*I) + eq*((-392. + 16.*I) + 481.*eq)]]


This expression cannot be split between the real and imaginary parts because they are intertwined. Mathematica would give you a nice z=a+b*I but it can't. Therefore it uses Im[...] because it cannot decompose it any further.

Try assigning value ranges for eq and finding the limits on z for the different values. Do bear in mind that eq is by definition a complex number too.

• Please don't forget to format your code blocks in markdown; see editing help for details. Feb 1 '16 at 6:33