0

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.

pajczur
  • 359
  • 3
  • 11
  • 1
    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 01 '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 01 '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 01 '18 at 23:41
  • 1
    "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 01 '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 02 '18 at 07:34

2 Answers2

2

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

MBaz
  • 15,314
  • 9
  • 30
  • 44
Cedron Dawg
  • 7,560
  • 2
  • 9
  • 24
1

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:

enter image description here

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: enter image description here 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?

Peter K.
  • 25,714
  • 9
  • 46
  • 91
pajczur
  • 359
  • 3
  • 11
  • 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 02 '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 02 '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 02 '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 02 '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 02 '18 at 15:47
  • So doesn't it represent the plane of real and imag ? – pajczur May 02 '18 at 18:11
  • The snail lives in the complex plane, but that is not what it is made of. Hint: It's only half the story. – Cedron Dawg May 02 '18 at 20:54
  • You give me puzzle :) Please tell me straight what do you mean? Please :) Believe me I have too much puzzles now. They are slowly killing me :) – pajczur May 03 '18 at 11:16
  • The worst thing is I suppose I know what you mean. But you told "Learn what the little snail really represents in terms of the DFT and you will have your answer". And I still have no answer that's why I am not sure if I know what you mean. Yes I know that little snail represents wave as a spiral, other words as a 3D wave, but I don't know how to get that third dimension I have just 2D wave. I know that third dimension is the same as second but shifted by one $ \pi $. But I need to shift by $ \pi $ not whole signal but each freq separately, but not sure how to do that. I know there is Hilbert.. – pajczur May 03 '18 at 11:24
  • transform, but not sure how to use it. Can I use it just straight on the 2D wave, or first should I perform DTFT, then Hilbert transform, and then inverse DTFT? I remind I just want to "rotate" (not sure how to call it) my square wave like on my first gif to the form like it is on my second gif. But I don't have any "snail" :) I just have 2D square wave (first D is time, second D is amplitude) – pajczur May 03 '18 at 11:29
  • I think MM's comment to your question is very applicable. You want fast quick spoonfed answers without having to understand the basis of them. Yes, you have to understand complex numbers to understand the DFT. Yes, you have to understand Euler's equation to understand the DFT. The "snail" is a pictorial representation of the inverse DFT operation using the lower half of the DFT. When you understand that statement, and have read my first three blog articles and understand them, then you can come back with more questions. – Cedron Dawg May 03 '18 at 15:09
  • Ok, we have the deal :) – pajczur May 03 '18 at 17:23
  • Great thanks all of you for your help, it helped me much to understand the topic. Thanks a lot – pajczur May 07 '18 at 12:43