Hi guy\'s I\'m working on simple signals and I want to calculate the Fourier transform of a signal, get the magnitude and phases, then reconstruct the original signal from that.
There is no such numerical instability in the FFT. The problem is that roundoff errors give a very small imaginary part in the recovered signal x_i. That's normal. The real part of x_i correctly reproduces x, whereas the imaginary part of x_i is very small. You can check with stem(real(x_i)) and stem(imag(x_i))
Now stem(x_i) with complex x_i plots the imaginary part versus the real part. On the othe hand, stem(1:length(x_i),x_i) (or of course stem(real(x_i))) plots the real part of x_i. Note that this is consistent with plot's behaviour (see also the answer to this question)
So just plot the real imaginary parts of x_i separately with stem. You'll see that the real part reproduces x as expected, and the imaginary part is negligible (of the order of eps).