I am looking for a sequence of functions $K_n(x)$ with $$ \lim_{n\to \infty}\int_{-\frac{\pi}{2n}}^{\frac{\pi}{2n}}K_n(x)f(x)\mathrm dx=f'(0) $$ for a smooth function $f:\mathbb{R}\to\mathbb{R}$. I have just proven (another sub part of the problem) that $$ \lim_{n\to \infty}\int_{-\frac{\pi}{2n}}^{\frac{\pi}{2n}}\frac{n}{2}\cos (nx) f(x)\mathrm dx=f(0) $$ through a change of variables and integration by parts. Is there an obvious way to modify the above solution I am missing? Is there perhaps a Fourier series solution?
Thanks for any hints and help!
edit: Here is the solution to the first part of the problem $$ \lim_{n\to \infty}\int_{-\frac{\pi}{2n}}^{\frac{\pi}{2n}}\frac{n}{2}\cos (nx) f(x)\mathrm dx\stackrel{\text{IBP}}= \lim_{n\to \infty}\frac{n}{2}\left[ \frac{1}{n}(f(x)\sin(nx)\vert_{-\frac{\pi}{2n}}^{\frac{\pi}{2n}}-\frac{1}{n}\int_{-\frac{\pi}{2n}}^{\frac{\pi}{2n}}f'(x)\sin(nx)\mathrm dx \right]\\ =f(0)-\frac{1}{n}\int_{-\frac{\pi}{2n}}^{\frac{\pi}{2n}}f'(x)\sin(nx)\mathrm dx $$ but the final integral tends to $0$, since $$ \left| \frac{1}{n}\int_{-\frac{\pi}{2n}}^{\frac{\pi}{2n}}f'(x)\sin(nx)\mathrm dx \right |\leq \\ \bigg | \frac{\pi}{n^2}\sup_{x\in [-\pi/2, \pi/2]} f'(x) \bigg |\to 0 $$
You did the computation already, but I'll explain the situation in general. Suppose that functions $\phi_n$ converge to the Dirac $\delta$ in the sense of distributions, meaning $$ \lim_{n\to \infty}\int_{\mathbb{R}} \phi_n(x)f(x)\, dx = f(0) $$ for smooth compactly supported functions $f$. Then the functions $\psi_n = -\phi_n'$, with the derivative understood in the sense of distributions, satisfy $$ \lim_{n\to \infty}\int_{\mathbb{R}} \psi_n(x)f(x)\, dx = f'(0) $$ The reason is integration by parts: $\int_{\mathbb{R}}(-\phi_n(x))'f(x)\, dx = \int_{\mathbb{R}} \phi_n(x)f'(x)\, dx \to f'(0)$.
In your situation $\phi_n(x) = \frac{n}{2} \cos nx$ restricted to $|x|<\pi/(2n)$. This is a continuous piecewise smooth function, so its distributional derivative is the same as the regular one: $\psi_n(x) = -\phi_n'(x) = \frac{n^2}{2} \sin nx$ restricted to $|x|<\pi/(2n)$.
And since $\phi_n$ and $\psi_n$ are compactly supported, it does not matter whether $f$ is compactly supported; smoothness is enough.