Non-negativity of the Fourier series Let there be a decomposition $φ(x)=\displaystyle\sum_{n=1}^\infty c_n\sin{nx}$ on the segment $[0,π]$, and on our segment $φ(x)≥0$. How do I prove that the series $\displaystyle\sum_{n=1}^\infty c_ne^{-n^2} \sin{nx}$ converges to a non-negative function on $[0, π]$?
Let me give a solution for the case of a continuous piecewise smooth function $φ(x)$. Consider a boundary value problem:
$$u_t=u_{xx},\,0\lt x \lt \pi, \, t\gt 0$$
$$u(x,0)=φ(x)$$
$$u(0,t)=u(\pi,t)=0.$$
According to the maximum principle for the heat equation, the continuous solution $u(x,t)$ reaches its maximum and minimum values only at the boundary of the considered region, i.e. or at $x=0$, or at $x=π$, or at $t=0$.
It remains to write down the solution to the problem by the method of separation of variables(due to the conditions on $φ(x)$, this solution will be continuous): $u(x,t)=\displaystyle\sum_{n=1}^\infty c_ne^{-n^2t} \sin{nx}$, where $\displaystyle\sum_{n=1}^\infty c_n\sin{nx}=φ(x)$ and substitute $t=1$.
The task seemed to me beautiful. It was not possible to find any "direct" solution (even in the class of continuous functions). If someone suggests one, I will accept it as an answer.
 A: Fix $\epsilon$.
Since $\phi\in L^2$ and continuous functions are dense in $L^2$, there exists $f\in C([0,\pi])$ such that $\|f-\phi\|_2\leq\epsilon$.  Moreover, since $\phi\geq0$, the function $f^+=\max{(f,0)}$ must be closer to $\phi$…thus we may assume $f\geq0$ as well.  (Likewise for vanishing at $\{0,\pi\}$.)
Write $f(x)=\sum_{n=1}^{\infty}{d_n\sin{nx}}$ formally; then $d_n=\langle f,\sin{(n(\cdot))}\rangle$ and $c_n=\langle\phi,\sin{(n(\cdot))}\rangle$.  By Cauchy-Schwarz, \begin{align*}
|d_n-c_n|&=|\langle f-\phi,\sin{(n(\cdot))}\rangle \\
&\leq\|f-\phi\|_2\|\sin{(n(\cdot))}\|_2 \\
&\leq\epsilon\cdot1
\end{align*}  (I may have dropped a constant or two.)
In fact, the series for $\phi$ converges a.e. by Carleson's theorem.  So \begin{align*}
\phi(x)=\sum_{n=1}^{\infty}{c_ne^{-n^2}\sin{nx}}&\geq\sum_{n=1}^{\infty}{\left(\begin{cases}
d_n-\epsilon&\sin{nx}\geq0\\
d_n+\epsilon&\sin{nx}<0
\end{cases}\right)e^{-n^2}\sin{nx}} \\
&=\sum_{n=1}^{\infty}{d_ne^{-n^2}\sin{nx}}-\epsilon\sum_{n=1}^{\infty}{e^{-n^2}|\sin{nx}|}
\end{align*}  Call the first term $u$ and the second $\epsilon\theta$.  By the argument you give in the problem, $u\geq0$.  Taking $\epsilon\to0^+$, it suffices to find a uniform bound on $\theta$.
But $$\sum_{n=1}^{\infty}{e^{-n^2}|\sin{nx}|}\leq\sum_{n=1}^{\infty}{e^{-n^2}}\leq\sum_{n=1}^{\infty}{e^{-n}}=\frac{1}{e-1}$$  So we're done.
A: Here a probabilistic take on the question.
Let $(B_t)_{t\ge 0}$ be standard Brownian motion on $[0,\pi]$, with both endpoints absorbing barriers. Let $T:=\inf\{t>0: B_t \in\{0,\pi\}\}$. Using a little martingale theory you can show that
$$
e^{-n^2t/2}\sin(nx)=E^x[\sin(nB_t); t<T], \qquad 0\le x\le\pi, t>0, n=1,2,\ldots.
$$
(The notation $E^x$ indicates expectation under the condition that $B_0=x$.)
Multiply by $c_n$, sum over $n\ge 1$, and specialize to $t=2$. We can bring the summation inside the expectation on the right because $\sin$ is bounded and $e^{-n^2}$ decays rapidly. There results
$$
\sum_{n=1}^\infty e^{-n^2}c_n\sin(nx)=E^x\left[\sum_{n=1}^\infty c_n\sin(nB_2); 2<T\right]=E^x[\varphi(B_2); 2<T].
$$
Because $\varphi\ge 0$ by hypothesis, the sum on the left is also non-negative. (N.B. The function $(x,t)\mapsto E^x[\varphi(B_t); t<T]$ is the solution to a modified form of your your boundary value problem — replace $u_{xx}$ with ${1\over 2}u_{xx}$.)
It may be worth noting that the second expectation on the right in the last display is a smooth function of $x\in(0,\pi)$ for any bounded measurable $\varphi$.
