What is the relationship between the Fourier transform of a periodic function and the coefficients of its Fourier series?
I have a following piecewise function: $y(t) = \begin{cases} 0, & -\pi < t < -\frac \pi 2, \\ -4, & -\frac \pi 2 <t < 0, \\ 4, & 0 < t < \frac \pi 2, \\ 0, & \frac \pi 2 < t < \pi. \end{cases}$
I computed the Fourier series which gave the sine coefficients $\dfrac 8 {m\pi} (1-\cos \dfrac {m\pi} 2)$.
I also computed the Fourier transform which gave $\dfrac {-4 \Bbb i} {\pi u} (1 - \cos(u \pi^2))$, but letting $u=-\dfrac n {2\pi}$, it gives $\dfrac {8 \Bbb i}n (1 - \cos( \dfrac {n\pi} 2))$.
I can see that the Fourier transform differs by a factor of $\pi$ from its Fourier series counterpart, but why is that, and what does it mean?
Suppose $f$ is a periodic function on $\mathbb R$ with period $p$, with Fourier series $$ f \sim \sum_{n\,\in\,\mathbb Z} c_n e^{2\pi inx/p} $$ The inner product $\langle f,g\rangle = \frac 1 p\int_0^p f(x)\,\overline{g(x)}\, dx$ (where $a\mapsto \overline{a}$ is complex conjugation) is used to determine the coefficients, which must satisfy $$ c_n = \left\langle x \mapsto \sum_{n\,\in\,\mathbb Z} c_n e^{2\pi inx/p} ,\ x\mapsto e^{2\pi mx/p} \right\rangle = \langle f, x\mapsto e^{2\pi mx/p} \rangle = \frac 1 p \int_0^p f(x) e^{-2\pi inx/p} \, dx. $$ (The fraction $1/p$ makes the inner product of $x\mapsto e^{2\pi i nx/p}$ equal to $1$.)
Now look at $$ \int_{-\infty}^\infty f(x) e^{-2\pi itx} \, dx. \tag 1 $$ It would be nice to be able to show that if $t\not\in\mathbb Z$, then the value of the integral in $(1)$ is $0$, but what if $t\in\mathbb Z$? Then the integral from $0$ to $p$ has some generally nonzero value, and the integral from $-\infty$ to $\infty$ is a some of infinitely many copies of that value, and so diverges to $\infty$ (not $+\infty$ or $-\infty$, but the $\infty$ that is approaches by fleeing in any direction in $\mathbb C$).
However, the theory of "generalized functions" such as Dirac's delta now comes to the rescue. Dirac's delta function $\delta$ is not a "function" in the sense of taking a number as its input and returning a number as its output. It has the property that $$ \int_{-\infty}^\infty f(x)\delta(x)\,dx = f(0) \tag 2 $$ and the perhaps strange-seeming property that $$ \int_{-\infty}^\infty f(x)\delta'(x)\,dx = -f'(0). \tag 3 $$ This leaves a bunch of problems of how things are to be defined; for example, we cannot define differentiation of the delta function by the usual limit of the difference quotient, and in fact we cannot even define the Fourier transform by the usual integral construed in the usual sense.
However, we will have an answer to the posted question: $$ \text{If } f(x) = \sum_{n=-\infty}^\infty c_n e^{2\pi inx/p} \text{ then } \hat f(t) = \sum_{n=-\infty}^\infty c_n \delta\left( t-np \right). \tag 4 $$ In order to do all of this, one needs to define integrals differently from the usual way in order to accomodate things like $(2)$ and $(3)$ above; one must defined convergence of sums like $(4)$ differently, and one must defined Fourier transforms of generalized functions $T$ by the relation $\langle \hat T, \varphi \rangle = \langle T, \hat\varphi \rangle$ where $\varphi$ is a certain kind of particularly well-behaved function belonging to a class of functions that enjoys the remarkable property of being closed under the Fourier transform.
This is all covered in Theory of Distributions: an non-technical introduction, by Ian Richards and Heekyung Youn, especially pages 77–88 (if there's an edition later than 1990, then the page numbers may be different).