  In this paper we propose a method to approximate the Gaussian function on
${\mathbb R}$ by a short cosine sum. We extend the differential approximation
method proposed in [4,39] to approximate $\mathrm{e}^{-t^{2}/2\sigma}$ in the
weighted space $L_2({\mathbb R}, \mathrm{e}^{-t^{2}/2\rho})$ where $\sigma, \,
\rho >0$. We prove that the optimal frequency parameters $\lambda_1, \ldots ,
\lambda_{N}$ for this method in the approximation problem $
\min\limits_{\lambda_{1},\ldots, \lambda_{N}, \gamma_{1} \ldots
\gamma_{N}}\|\mathrm{e}^{-\cdot^{2}/2\sigma} - \sum\limits_{j=1}^{N} \gamma_{j}
\, {\mathrm e}^{\lambda_{j} \cdot}\|_{L_{2}({\mathbb R},
\mathrm{e}^{-t^{2}/2\rho})}$, are zeros of a scaled Hermite polynomial. This
observation leads us to a numerically stable approximation method with low
computational cost of $\mathit{O}(N^{3})$ operations. Furthermore, we derive a
direct algorithm to solve this approximation problem based on a matrix pencil
method for a special structured matrix. The entries of this matrix are
determined by hypergeometric functions.
  For the weighted $L_{2}$-norm, we prove that the approximation error decays
exponentially with respect to the length $N$ of the sum. An exponentially
decaying error in the (unweighted) $L^{2}$-norm is achieved using a truncated
cosine sum.
