I have coded a discrete fourier transform script in python sageMath. I am trying to analysis the frequency spectrum of the function 1-2t. The graph for 1-2t from 0 to 4 is below:
When I run the DFT code I get the following frequency spectrum graph.
The graph has a spike at zero. Then slope downward towards 0 in x-axis. But it has some spike at 0.5,1,1.5 and 2 frequencies. Does it mean the function (1-2t) is mainly composed of four sinusoids of the above frequencies. The function 1-2t is not a periodic function. But Fourier transform is used to analysis non-periodic functions to find their frequency spectrum. But if I create 4 sine wave of the frequency 0,0.5,1,1.5 and 2 Hz and add them together I do not get the graph back. I get something like the following, which is nowhere near the original graph of 1-2t.


