# How to "rotate the phase"?

I have problem, not sure how to call it but I think it's something called "phase rotating", but not sure.

I make fast Fourier transform on simply square wave, and then I make inverse fast Fourier transform - just for fun :) and after this forward/backward FFT on square wave I expect on a wave graph something like that: Could anyone help me, which parameter I should change, to fix it?

• did you change the data after the FFT and before the iFFT? it does look like a phase change, but even a phase change requires changing the data. Apr 29 '18 at 23:43
• I am not sure what you are asking. I didn't change anything. Just make FFT and on the output of FFT I make inverse FFT, that's all. Apr 29 '18 at 23:57
• I tried it with the radix-2 FFT and mixed radix FFT, and the same results. Apr 29 '18 at 23:57
• maybe it's important: on the output of forward FFT I perform magnitude calculations by: $\sqrt { real^2 + imag^2 }$. But on the output of inverse FFT I just take real values without any calculations. Maybe I should use in some way the imaginary numbers also? Apr 30 '18 at 0:01
• The output of your fft should yield complex number. You must feed the same complex number to the ifft to get the same result as the input of the fft. If you do the ifft of the magnitude of the spectrum, you'll get a different result. Also, you could share your code, that would help Apr 30 '18 at 0:30

Ok I give the answer by myself, but it’s only half of answer. As I know we can rotate $90^o$ the phase by multiplying the wave by $j$ - imaginary number. And to rotate it to $180^o$ we need multiply by $j^2$ (or just $-1$ which is the same). To rotate $270^o$ we need to multiply by $j^3$, and so on...

But if we want rotate something between? For example $45 ^o$ or $30^o$. What we need to multiply by?

• Use Euler's formula: $\cos(\theta) + j\sin(\theta)$ to rotate by $\theta$. Jul 1 '18 at 7:25
• Thanks firdes, your comment is helpfull. I had figured it out by my own that to rotate by some angle between 0-90 degree I just need to multiply signal by $i^(something between zero and one)$. But your comment gives me answer how to rotate by exact degree. Thanks. Jul 1 '18 at 8:00

I like to use $i$, instead of $j$.
The underlying rule, which comes from the exponential nature of the unit circle, is that when you multiply two complex numbers their angles get added. Thus the angle to $i$ is $90^o$ ($\pi/2$ radians), so every time you multiply by $i$ you rotate the complex number by a quarter circle. The other rule about multiplying complex numbers is that the magnitude of the product is the product of the magnitude. Since $|i|=1$ it doesn't stretch any number you multiply it by.
You can rotate any complex number by $p$ quarter circles by multiplying it by $i^p$. You can pick any point on the unit circle, and if you multiply a complex number by the value of the complex number at that point, you will rotate the first complex value by the angle to the point.