# How to convert wave from real to complex and vice versa? [closed]

I have wave expressed by array of real numbers (double in C++). But I want to express it as a complex. I tried to create complex variable and assign to its real the array of my wave and to its imaginary just array of zeros. OK it's complex now. But I feel there is something wrong. It's not authentic complex. It's just surrogate. For example I can't manipulate in phase (only reverse phase). When I multiply it by for example $i^{0.4}$ it's just changing amplitude little bit but phase is without change.

In the other hand if I have authentic complex wave how to express it as a real numbers but including information from imaginary values?

For any help great thanks in advance.

• It sounds like you have dangerous half-knowledge of passband signals and equivalent complex baseband signals. You might really want to read up on these, otherwise we'll just be patching singular misconceptions here and there, and not really addressing your overall problem. I really think a book chapter helps a lot more than getting answers here! – Marcus Müller May 1 '18 at 23:12
• Hello great thanks for your advice. But I am really sure any answer to the topic could help me. Or if you are sure it's totally wasting the time, maybe could you propose some book to read and exact chapter (at that moment I don't want to read whole book, I just want to get answer for my question). – pajczur May 1 '18 at 23:40
• And what did you mean by "dangerous half-knowledge". Especially why dangerous? :-) I am just working with audio, I don't think I could hurt anyone :-) – pajczur May 1 '18 at 23:41
• "When I multiply it by for example $i^{0.4}$ it's just changing amplitude little bit but phase is without change." You're doing something wrong. If $a$, $b$ anc $c$ are real, then $a(b+jc)=ab+jac$ which is complex and has a non-trivial phase. BTW, to change the phase by $\phi$, multiply your signal by $e^{j\phi}$. – MBaz May 1 '18 at 23:56
• Are you using the complex data type already? That would simplify things for you, provided that you don't then proceed with some sort of conceptual errors. Also, it is impossible to turn a complex to real. This is why it is complex. It serves an entirely different purpose. You can always get the magnitude of a complex but the complex can possibly be rotating and the real will be showing a constant value. Think about the magnitude of the FFT for example. – A_A May 2 '18 at 7:34

Rather than saying the questions you are asking are non-sensical, I will say they reveal a lack of understanding of complex numbers. There is lots of material to be had with a few simple searches. I would also recommend that you read my blog article The Exponential Nature of the Complex Unit Circle which gives an explanation of Euler's equation which is absolutely essential to understand in order to comprehend the meaning of DFT bin values.

For your first question: Technically, a real number is a complex number with a zero imaginary component. So setting the real part equal to your values and the imaginary part to zero is the correct method. When you multiplied it by $i^{0.4}$ it should have rotated each value a tenth of a cycle. Thus the amplitude stays the same, but the phase shifts by $\pi/5$ radians.

For your second question: A complex number consists of two values. A real number consists of one. Therefore converting a complex number to a real number is a non-sensical proposition. However, you can calculate the magnitude, which is a real number. You can also ask what the real part is, which is also a real number. The imaginary part is a real number multiplied by $i$.

A real tone is a sinusoidal, flat as a pancake. A complex tone is a spiral, like a slinky. The definitions I use in my blog articles are:

$$S_n = A \cos( \alpha n + \phi )$$

For a real tone, and:

$$S_n = A e^{i (\alpha n + \phi)}$$

For a complex one.

Notice that a real valued tone is just the average of two complex tones:

$$\frac{ A e^{i (\alpha n + \phi)} + A e^{-i (\alpha n + \phi)} }{2} = A \frac{ e^{i (\alpha n + \phi)} + e^{-i (\alpha n + \phi)} }{2} = A \cos( \alpha n + \phi )$$

Because

$$\cos( \theta ) = \frac{ e^{i\theta} + e^{-i\theta} }{2}$$

Hope this helps.

Ced

I decided to answer my own question cause I need more space. To all of you who says:

... converting a complex number to a real number is a non-sensical proposition.

I prepared some funny graph which is very popular in all Fourier concern videos on youtube. Probably all of you met it before: As you probably know that rounding and wraping like snail lines are moving on plane of real an imaginary values. I made it little bit different then everybody, I mean here horizontal values are imaginary, and real are vertical values. So the graph on the right is just wave real values and time, but converted in some way from complex values? Am I wrong? If I have imaginary numbers all zeros, then that rounding snail would be just vertical line going up and down, but right graph representation of wave real values would be the same as it is now.

But when I turn the knob - which represent the $$complexValue * i^{knobValue}$$ My real representation of wave (right graph) also change according to the knob value, and according to imaginary values: So the right graph is dependent of real and imag values. But still shows only real values. That's why I think the right graph is in some way complex numbers converted to real numbers but including in some way information from imaginary.

Where I am wrong?

• What you are doing can be called a projection, or a function of, but "converting" is not a correct usage of the term. When you convert something, you change its representation without loss of information, meaning you can convert it back. The samples you cite, and the cases I gave in my answer, are a way to derive a real value form a complex value, but they are not conversions. A change from cartesian form $x + i y$ to polar form $r e^{i\theta}$, is a conversion. The magnitude $\sqrt{ x^2 + y^2 }$ or $\|r\|$ is a function of a complex number onto the reals. – Cedron Dawg May 2 '18 at 14:39
• Great thanks for comment, but still can’t find the answer for how to rotate phase in my audio signal which is expressed only by real numbers :) – pajczur May 2 '18 at 14:48
• Again, you aren't using terminology properly. Phases don't get rotated. You can shift them. The issue is made a little more confusing because the term "phase" can either be applied to the argument of the sinusoidal as a whole, or the constant value within it. In either case, it is a real number and adding a value to it moves the overall function along the domain. For a complex tone (the slinky), rotating the wave (not the phase) is the same as shifting it. For a real tone, the concept of rotating is not applicable. Audio signals are real valued. – Cedron Dawg May 2 '18 at 15:01
• So, is there any way to transform my real values square wave (first gif) to be like on the second gif? How to do that? – pajczur May 2 '18 at 15:24
• Those are pretty pictures. Learn what the little snail really represents in terms of the DFT and you will have your answer. – Cedron Dawg May 2 '18 at 15:47