# Unstable behavior of Discrete Fourier Transform and Fourier Transform alternatives

I have come across a "weird" behavior of the Discrete Fourier Transform (which I will refer to from now as DFT).

suppose $$x=(1,-1,1,-1)$$ The real part of the DFT of $$x$$ is $$Real(DFT(x))=(0,0,4,0)$$ From a signal processing perspective, since $$x$$ oscillates between the maximum and minimum of it's entries in every sequential coordinate, it is reasonable that $$DFT(x)$$ gets it's maximum at the coordinate which refers to the highest non overlapping frequency. Also $$x$$ is some what of a "pure" signal (essentially a sinusoidal signal) and does not consist of any other frequency.

Now lets take a look at a different signal $$y=(1,-1,1,-1,1)$$ The real part of the DFT of $$y$$ is $$Real(DFT(y))=(1,1,1,1,1)$$ Again from a signal processing perspective $$y$$ resembles $$x$$ in the time domain, but not in the frequency domain.
This behavior feels unstable: small change in the signal leads to big change in the frequencies.
my questions are:
1. What are other weird behaviors of DFT?
2. Are there any stable alternatives to DFT? (in a sense of capturing the frequencies/repetitiveness of a signal)

One issue with your argument is that you consider only the real part of the DFT (why?). You might as well consider only the imaginary part, which, for the first case ($$[1,-1,1,-1]$$) equals the all-zero vector ($$[0,0,0,0]$$), which, you could also "argue" makes no sense as you have a non-zero signal.
Your example corresponds to the discrete-time signal $$x[n]=\cos\left(2\pi \frac{1}{2} n\right),n=0,1,\ldots,N-1$$, with $$N=4$$ and $$N=5$$ for the first and second case, respectively. This is a "tough" signal to get insights from its DFT as the number of samples ($$N$$) is very small. However, the DFT output is perfectly reasonable.
Recall that the DFT is essentially the sampled discrete-time Fourier transform (DTFT) of the signal, defined as $$X(e^{i2\pi f})=\sum_{n=0}^{N-1}x[n]e^{-i2\pi f n},f\in[0,1)$$. In the plot below, the magnitude of the DTFT $$|X(e^{i2\pi f})|$$ is shown, along with its samples $$|X(e^{i2\pi n/N})|,n=0,1,\ldots,N-1,$$ corresponding to the magnitude of the DFT.
Looking at the DTFT magnitudes one can clearly see that the signal has most of its energy at $$f=1/2$$, as expected for a time-domain signal being a truncated version of a cosine with the same frequency. The DFT samples also suggest the same (although one may need some experience to see that from the DFT samples alone).