Approximating periodic functions by smooth functions in $L^p$ Given $f:\mathbb R^n\to\mathbb C$ locally $L^p$ and periodic (i.e. $f(x+y)=f(x)$ for any $y\in\mathbb Z^n$), can we find smooth periodic $f_n$ s.t. $\|f-f_n\|_{L^p(B)}\to0$, where the integral for the norm is taken over the box $B=(0,1)^n$?

I know that in general, smooth functions are dense in $L^p$. So since periodic functions are basically defined by their values on the box $B$, I feel like this could be helpful?
I have also tried considering Fourier transforms and combinations of $x\mapsto \exp(2\pi i\langle x,a\rangle)$ for $a\in\mathbb Z^n$, but with no success.
 A: You can do even better than approximate with smooth periodic functions. You can approximate with trigonometric polynomials (which, in particular, are analytic periodic functions). The key is the Fejér kernel.
Let me switch notations and call $\mathbb T^n=[0, 1]^n$ (which is what you called $B$ in your question). This notation change is not necessary at all, it is just more common.
Given $f\in L^p(\mathbb T^n)$, with $p\in [1, \infty)$, letting $\hat{f}(m)=\int_{\mathbb T^n} f(x)\exp(-2\pi i \langle m, x\rangle)\, dx$ for $m\in \mathbb Z^n$, we have that the following Cesàro sum can be written as a convolution;
$$
\frac{1}{M}\sum_{N=0}^{M-1}\sum_{\lvert m \rvert \le N} \hat{f}(m)\exp(2\pi i \langle x, m\rangle)= f\ast F_M(x), $$
where $F_M$ denotes the Fejér kernel. All information on this can be found on the Wikipedia page.
What is important is that the left-hand side of the previous equation is a trigonometric polynomial. Now since the Fejér kernel is a "summability kernel", also known as an "approximation of the identity", we have that
$$
\lim_{M\to \infty} \lVert f\ast F_M - f\rVert_{L^p(\mathbb T^n)}=0, $$
which in particular proves the required approximation; see the previously linked Wikipedia page.
Remarks.

*

*It is important to perform a Cesàro sum instead of a standard partial sum. A standard partial sum would lead to the convolution $f\ast D_M$, where $D_M$ is the Dirichlet kernel, which is much more involved than the Fejér one.

*This procedure will also work for $p=\infty$, provided that $f$ is continuous. In this case, $f\ast F_M$ is a sequence of trigonometric polynomials that converges to $f$ uniformly on $\mathbb T^n$.

A: Yes we can. Consider a smooth approximation $(f_k)_k$ on $B$. Now consider a family of $C^\infty$ plateau functions $1 \ge \chi_r \ge 0$ that is equal to $1$ on $B(\frac{1}{2}, \frac{1}{2}-r)$ and $0$ on $B(\frac{1}{2}, \frac{1}{2}- \frac{r}{2})^c$.
You can extract a suitable subsequence $(k_n)$ of the natural sequence $(k)_k$ such that the product $\tilde f_n(x)=f_{n}(x) \times \chi_{(1/k_n)}(x)$ will converge to $f$ on $B$. You can easily periodize this sequence.
