22/02/2026
This example demonstrates how a simple sine wave is analyzed in both the time and frequency domains using Python.
First, a 50 Hz sine wave is generated. The sampling frequency is set to 1000 Hz, meaning 1000 samples are taken per second. The time vector is created for N = 1024 points. The signal is defined as:
x = sin(2Ï€ f t)
This produces a clean periodic waveform in the time domain. The upper plot shows amplitude versus time, where you can clearly see repeating cycles of the sine wave.
Next, the Fast Fourier Transform (FFT) is applied using np.fft.fft(). The FFT converts the signal from the time domain into the frequency domain. Instead of showing how the signal changes over time, it shows how much of each frequency is present in the signal.
The lower plot shows magnitude versus frequency. A sharp peak appears at 50 Hz, confirming that the signal contains a strong 50 Hz component. Since it is a pure sine wave, no other significant frequency components are present.
This example clearly illustrates the relationship between time-domain representation (waveform shape) and frequency-domain representation (spectral content).