# About Complex Numbers, Real part and Imaginary part (symbolic calculus) [closed]

Ok, I need some great help otherwise I'll go nuts.

I have this function:

$$f(s) = \frac{\pi}{2\sqrt{s}} - \frac{\text{arcsec}(\sqrt{s})}{\sqrt{s-1}}$$

What I have to do is to take $s = +i\omega$, hence it becomes

$$f(s = +i\omega) = \frac{\pi}{2\sqrt{i\omega}} - \frac{\text{arcsec}(\sqrt{i\omega})}{\sqrt{i\omega -1}}$$

No big deal so far.

Henceforth the pain: I have to separate Real and Imaginary part. Since I ignore how to do it with Mathematica (because it won't do anything, since I am not able to tell it that $\omega$ is a natural number), I tried to do it by hands.

No big problem in finding that (piece by piece)

$$\sqrt{i\omega} = \frac{\sqrt{2\omega}}{2}[1 + i]$$

and maybe also that

$$\sqrt{i\omega -1} = \large e^{\frac{1}{4}\ln(1+\omega^2)[i\sin(\arctan(\frac{\sqrt{1+\omega^2}+1}{\omega^2})) + \cos(\arctan(\frac{\sqrt{1+\omega^2}+1}{\omega^2}))]}$$

And then again no problem in understanding that

$$\sin\arctan(Y)) = \frac{Y}{\sqrt{1 + Y^2}}$$

and a similar identity for the cosine.

And again: no problem in computing the hellish arc secant term to find

$$\text{arcsec}(\sqrt{i\omega}) = \frac{\pi}{2} + \frac{1}{\sqrt{2\omega}}(1 - i) + \frac{1}{2}\sqrt{1 + \frac{1}{\omega^2}} + i\arctan(\omega - \sqrt{\omega^2+1})$$

Fiiiiine!

But what if I wanted to check?

I don't claim for the complete commands, I just need some help with the procedure to make Mathematica to do those calculations for me, or at least to simplify a bit the things.

Because now I have to arrange the whole expression, and I will have to find the real and imaginary part of that amusing gizmo.

So to be clear: how could I make Mathematica to find real and imaginary part of a complex numbers with a symbolic calculation? Here $\omega$ is a natural number. Also I'd like to check if what I did is correct or not.

Thank you very much!

• Have you tried using ComplexExpand? For example, something like Assuming[w > 0, Simplify@ComplexExpand[Sqrt[I w], TargetFunctions -> {Re, Im}]]. – Carl Woll May 1 '17 at 22:25
• Might have better luck with responses if actual code is posted. – Daniel Lichtblau May 1 '17 at 22:32
• @CarlWoll That cute small code line is awesome! Let me try it again! – Henry May 1 '17 at 22:38
• @CarlWoll Hey, it seems like your tiny code made the maths! I guess I can consider the doubt as solved. Blimey, how afternoonified you are! – Henry May 1 '17 at 22:42

A simple idea of how to check your result is as follows. Let us take the expression for ArcSec you derived above and calculate a difference between the function itself and this expression within a table. In the case of a correct expression it must be a list of zeros down to the MachinePrecision:

    Table[ArcSec[Sqrt[
I*\[Omega]]] - (\[Pi]/2 + (1 - I)/Sqrt[2 \[Omega]] +
1/2 Sqrt[1 + 1/\[Omega]^2] +
I*ArcTan[\[Omega] - Sqrt[\[Omega]^2 + 1]]), {\[Omega], 1, 10, 1.}]//Chop

(* {-1.99 + 1.86 I, -1.51 + 1.26 I, -1.32 + 0.996 I, -1.21 +
0.842 I, -1.13 + 0.741 I, -1.08 + 0.667 I, -1.03 +
0.611 I, -0.998 + 0.567 I, -0.97 + 0.531 I, -0.946 + 0.501 I}  *)


If I missed nothing, it is not the case.

There is a reasonably simple way to do this representation directly in Mma. This is your function:

f = \[Pi]/(2 Sqrt[s]) - ArcSec[Sqrt[s]]/Sqrt[s - 1] /. s -> I*\[Omega]


Try this:

 expr=Simplify[ComplexExpand[f,
TargetFunctions -> {Re, Im, Sign}], \[Omega] \[Element] Reals]

(* (1/(2 (\[Omega]^2 + \[Omega]^4)^(
1/4)))(-Sqrt[
Abs[\[Omega]]] (\[Pi] -
2 ArcTan[(1 + \[Omega]^2)^(1/4) Cos[1/2 ArcTan[1/\[Omega]]] +
Sin[1/2 ArcTan[0, \[Omega]]],
Cos[1/2 ArcTan[0, \[Omega]]] + (1 + \[Omega]^2)^(1/4)
Sin[1/2 ArcTan[1/\[Omega]]]] +
I Log[(1 + Sqrt[1 + \[Omega]^2] +
2 (1 + \[Omega]^2)^(1/4)
Sin[1/2 (ArcTan[1/\[Omega]] + ArcTan[0, \[Omega]])])/
Abs[\[Omega]]]) (Cos[1/2 ArcTan[-1, \[Omega]]] -
I Sin[1/2 ArcTan[-1, \[Omega]]]) + \[Pi] (1 + \[Omega]^2)^(
1/4) (Cos[1/2 ArcTan[0, \[Omega]]] -
I Sin[1/2 ArcTan[0, \[Omega]]]))  *)


Now to check:

Table[\[Pi]/(2 Sqrt[I \[Omega]]) - ArcSec[Sqrt[I \[Omega]]]/
Sqrt[-1 + I \[Omega]] -
1/(2 (\[Omega]^2 + \[Omega]^4)^(
1/4)) (-Sqrt[
Abs[\[Omega]]] (\[Pi] -
2 ArcTan[(1 + \[Omega]^2)^(1/4) Cos[1/2 ArcTan[1/\[Omega]]] +
Sin[1/2 ArcTan[0, \[Omega]]],
Cos[1/2 ArcTan[0, \[Omega]]] + (1 + \[Omega]^2)^(1/4)
Sin[1/2 ArcTan[1/\[Omega]]]] +
I Log[(1 + Sqrt[1 + \[Omega]^2] +
2 (1 + \[Omega]^2)^(1/4)
Sin[1/2 (ArcTan[1/\[Omega]] + ArcTan[0, \[Omega]])])/
Abs[\[Omega]]]) (Cos[1/2 ArcTan[-1, \[Omega]]] -
I Sin[1/2 ArcTan[-1, \[Omega]]]) + \[Pi] (1 + \[Omega]^2)^(
1/4) (Cos[1/2 ArcTan[0, \[Omega]]] -
I Sin[1/2 ArcTan[0, \[Omega]]])), {\[Omega], 1, 10,
1.}] // Chop

(*  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}  *)


Have fun!

Later edit: To address your question of how to ultimately separate within Mma the real and imaginary parts

One way to do this would be to first put in the expr the imaginary unit, I, equal to zero. This gives the real part:

exprRe = Expand[expr] /. Complex[0, x_] -> 0

(*  -((\[Pi] Sqrt[Abs[\[Omega]]] Cos[1/2 ArcTan[-1, \[Omega]]])/(
2 (\[Omega]^2 + \[Omega]^4)^(1/4))) + (
Sqrt[Abs[\[Omega]]]
ArcTan[(1 + \[Omega]^2)^(1/4) Cos[1/2 ArcTan[1/\[Omega]]] +
Sin[1/2 ArcTan[0, \[Omega]]],
Cos[1/2 ArcTan[0, \[Omega]]] + (1 + \[Omega]^2)^(1/4)
Sin[1/2 ArcTan[1/\[Omega]]]] Cos[
1/2 ArcTan[-1, \[Omega]]])/(\[Omega]^2 + \[Omega]^4)^(
1/4) + (\[Pi] (1 + \[Omega]^2)^(1/4) Cos[1/2 ArcTan[0, \[Omega]]])/(
2 (\[Omega]^2 + \[Omega]^4)^(1/4)) - (
Sqrt[Abs[\[Omega]]]
Log[(1 + Sqrt[1 + \[Omega]^2] +
2 (1 + \[Omega]^2)^(1/4)
Sin[1/2 (ArcTan[1/\[Omega]] + ArcTan[0, \[Omega]])])/
Abs[\[Omega]]] Sin[1/2 ArcTan[-1, \[Omega]]])/(
2 (\[Omega]^2 + \[Omega]^4)^(1/4))   *)


As soon as it is done the imaginary part is simply expr-exprRe:

exprIm = expr - exprRe // Simplify

(*   -(1/(2 (\[Omega]^2 + \[Omega]^4)^(1/4)))
I (Sqrt[Abs[\[Omega]]] (Cos[1/2 ArcTan[-1, \[Omega]]] Log[(
1 + Sqrt[1 + \[Omega]^2] +
2 (1 + \[Omega]^2)^(1/4)
Sin[1/2 (ArcTan[1/\[Omega]] + ArcTan[0, \[Omega]])])/
Abs[\[Omega]]] - \[Pi] Sin[1/2 ArcTan[-1, \[Omega]]] +
2 ArcTan[(1 + \[Omega]^2)^(1/4) Cos[1/2 ArcTan[1/\[Omega]]] +
Sin[1/2 ArcTan[0, \[Omega]]],
Cos[1/2 ArcTan[0, \[Omega]]] + (1 + \[Omega]^2)^(1/4)
Sin[1/2 ArcTan[1/\[Omega]]]] Sin[
1/2 ArcTan[-1, \[Omega]]]) + \[Pi] (1 + \[Omega]^2)^(1/4)
Sin[1/2 ArcTan[0, \[Omega]]])    *)


Have fun!

• Is there a way to force it to separate between Real and Im parts? Because there still remain mixed products... – Henry May 2 '17 at 14:53
• @Alan Turing I edited the answer to address your question. Please have a look. – Alexei Boulbitch May 3 '17 at 7:39
• Swell! Thank you so much my dear! – Henry May 3 '17 at 7:55
• Uhm, sorry for bothering: just another question: I tried your command with a simple function, that is f = Sin[s] + s - Sqrt[s] /. s -> I*[Omega] And when I told the command "expRe = Expand[expr]" et cetera, it gave me $$-\frac{(1+i) \sqrt{\omega }}{\sqrt{2}}$$ Which is not a real part alone... – Henry May 3 '17 at 14:14
• ComplexExpand[ReIm[func], TargetFunctions->{Re,Im}] with a Simplify postprocess step if desired. – Carl Woll May 3 '17 at 14:24