# 0.2 Sampling Bandlimited Signals

We can verify Shannon's sampling theorem. We can create bandlimited signals using sinusoidal signals and their linear combinations. Let's consider the signal

$$
y(t) = \cos(2\pi 5t) + 0.5\cos(2\pi 6t) + 0.25\cos(2\pi 10t),
$$

which is a linear combination of bandlimited signals, and hence a bandlimited signal.

{% hint style="success" %}
**Checkpoint:** Show that the space of bandlimited signals is a vector space. Then, guess its basis functions.
{% endhint %}

Let's simulate the bandlimited signal $$y$$and verify by plotting the spectrum.

```python
t_continuous = np.linspace(0,1,1000)
cosine = lambda A, f, t: A*np.cos(2*np.pi*f*t)

signal = cosine(1.0, 5, t_continuous) + cosine(.5, 6, t_continuous) \
            + cosine(.25, 10, t_continuous)
```

![A bandlimited signal -- linear combination of sinusoidal signals.](https://1719691385-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MetmKF4Nky-_P8tzlc8%2F-Mih1Ad-5zSeaxyKsHGF%2F-Mih36wUxXMLkHXEEbDD%2Fimage.png?alt=media\&token=b9d4d8dc-c588-4f5b-968e-d1df1738f989)

![Spectrum of the bandlimited signal composed using cosines.](https://1719691385-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MetmKF4Nky-_P8tzlc8%2F-Mih1Ad-5zSeaxyKsHGF%2F-Mih40Fw0q0Yj2xHvzZo%2Fimage.png?alt=media\&token=4c0f9ad7-a17b-4a68-8c71-590b65eec499)

The spectrum is non-zero at frequencies corresponding to the frequencies contained in the signal at 5 Hz, 6 Hz and 10 Hz. But let's analyse this a little more.

{% hint style="success" %}
***Checkpoint***:

* Is $$x\_{1}(t) = \cos(2\pi10t)$$ bandlimited? If yes, what is its bandwidth?
* Is $$x\_{2}(t) = \cos(2\pi10t)(u(t) - u(t-1))$$ bandlimited?

With this, comment why the FFT approximation to the Fourier transform is correct in the case above when the signals are sinusoidal.
{% endhint %}

Since the signal is known in closed-form, we can get exact samples by defining the sampled signal. We can then plot the spectrum and observe the effects. We know, using Shannon's sampling theorem, the signal is represented exactly when the sampling frequency is greater than $$20$$Hz.

```python
Fs = 30
t_discrete = np.arange(1,Fs+1)
sampled_signal = cosine(1.0, 5/Fs, t_discrete)\
            + cosine(.5, 6/Fs, t_discrete) \
            + cosine(.25, 10/Fs, t_discrete)
```

![DFT of the signal with 30 samples per second.](https://1719691385-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MetmKF4Nky-_P8tzlc8%2F-Mih5IUHQEeDoIwQMsJZ%2F-Mih6Fw4UpW5NqX9PMW4%2Fimage.png?alt=media\&token=c7ca4d4d-d268-4e46-923b-e0130f4a9447)

![DFT of the signal with 14 samples per second.](https://1719691385-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MetmKF4Nky-_P8tzlc8%2F-Mih5IUHQEeDoIwQMsJZ%2F-Mih6aJ63jzVUlbxLLwl%2Fimage.png?alt=media\&token=be366262-b9b0-49ab-bfef-da0e2811d427)

Notice that the signal sampled at$$30$$Hz has the identical non-zero spectral coefficients as the original signal, however, the signal sampled at$$14$$Hz does not resemble the spectrum of the original signal. Hence the signal sampled at$$30$$Hz can be perfectly recovered using an ideal lowpass filter.
