I was working on a question very similar to this post: Show that $\int_{-\pi}^\pi ~f(x) \cos (nx) \mathrm{d}\mu(x)$ converges to $0$ .
I want to show that $\lim_{n \rightarrow \infty}\int_{-M}^M f(x) \cos (nx) dx=0$ for a closed and bounded interval $[-M,M]$ provided $f\in L^1([-M,M])$. The answer to the link above says that for any step function $g$ in $[-M,M]$, $$\lim_{n \rightarrow \infty}\int_{-M}^M g(x) \cos (nx) dx=0.$$
I want to supply the details that will prove that the limit of the original integral will vanish. Since, step functions in $[-M,M]$ are dense in $L^1([-M,M])$, then there exists a sequence $(g_m)$ if step functions in $[-M,M]$ that converges to $f$ in the $L^1([-M,M])$ norm. We also know that up to a subsequence $(g_{m_{k}})$, it also converges pointwise a.e. to $f$. Therefore, since $$|g_{m_k}cos(nx)|\leq|g_{m_k}|,$$ and $$\lim_{k\rightarrow \infty}\int_{-M}^M|g_{m_k}|=\int_{-M}^M|f|,$$ then by the Generalized Lebesgue Dominated Convergence Theorem (we can 'pass the limit'): $$\lim_{n \rightarrow \infty}\int_{-M}^M f(x) \cos (nx) dx = \lim_{n \rightarrow \infty}\int_{-M}^M \lim_{k \rightarrow \infty} g_{m_k}(x) \cos (nx) dx $$ $$\lim_{n \rightarrow \infty}\int_{-M}^M f(x) \cos (nx) dx = \lim_{k \rightarrow \infty} \lim_{n \rightarrow \infty}\int_{-M}^M g_{m_k}(x) \cos (nx) dx=0.$$ This proves the theorem. Is my proof correct?