The problem
Five symbols, +1 −1 +1 +1 −1, leave one every T seconds: the symbol rate is R = 1/T. A square pulse per symbol has a spectrum running far past R. In a narrow channel the pulses smear into each other: intersymbol interference (ISI).
Nyquist's pulse
The receiver looks at the signal only once per symbol, at t = kT. So a pulse may spread over its neighbours' time, as long as it is exactly zero at their sampling instants: p(0) = 1 and p(kT) = 0 for every other k.
One pulse does exactly this: p(t) = sin(πt/T)/(πt/T), the sinc pulse. It is 1 at t = 0 and crosses zero at t = ±T, ±2T, ±3T and so on: at every other symbol's sampling instant.
Each symbol sends a scaled, delayed sinc, and the cable carries their sum. The pulses overlap everywhere, yet at t = kT all of them but one are zero. The samples read +1, −1, +1, +1, −1: no ISI.
The sinc's spectrum is a flat block from 0 to R/2, then nothing at all. No zero-ISI pulse fits in less. At R = 1 million symbols a second that is 500 kHz; a square pulse's main lobe alone reaches 1 MHz.
Real clocks are never exact, and sinc tails shrink only like 1/t. Sample 0.1T late and the tails of 100 symbols on each side can add up to 1.02: more than the wanted pulse, 0.98. A symbol can flip.
Raised cosine
Multiply the sinc by a smooth factor: p(t) = sinc(t/T)·cos(πβt/T) / (1 − (2βt/T)²). It keeps every zero at kT, but its tails fall like 1/t³. At t = 5.5T: sinc −0.058, raised cosine 0.0041 (β = 0.35).
The raised-cosine spectrum stays flat to (1 − β)R/2, then rolls down half a cosine wave to (1 + β)R/2. The roll-off β runs from 0 to 1. With β = 0.35 at 1 million symbols a second: 675 kHz instead of 500.
Back to symbols
The receiver samples the raised-cosine signal at each kT and keeps the sign: +1, −1, +1, +1, −1 come back. Even 0.1T late, the worst-case tails of 100 symbols on each side add up to only 0.27, so every sign survives.
In Python with numpy, np.sinc(x) is sin(πx)/(πx). The function p builds the raised cosine. Its samples h at −4T to 4T are 1 at the centre and 0 elsewhere, so convolving the symbols with h gives them back unchanged.
The working
# step 1/10 · square symbols a = +1 −1 +1 +1 −1 symbol period T (here 1 µs) symbol rate R = 1/T = 1 million per second square pulse, one T wide |P(f)| / T = |sinc(f·T)| main lobe to f = R, then sidelobes that fade only slowly sinc(u) = sin(πu) / (πu) ISI in depth: the lesson "Intersymbol interference"
Time is drawn in symbol periods T and frequency in units of the symbol rate R = 1/T; spectra are amplitude spectra divided by T. The example rate, 1 million symbols a second, is a chosen round number. Every curve is computed from the formulas in the model and checked against a DFT of the sampled pulse. The motion is slowed down a great deal: at 1 million symbols a second one symbol lasts 1 µs.