Is it possible to approximate $\cos(x)$ with a linear combination of Gaussians $e^{-x^2}$? I am interested in approximating $\cos x$ with a linear combination of $e^{-x^2}$. I am not an expert in approximation theory but there are a couple things that give me a bit of hope that it might be possible (and some other things that worry me it might not be possible or that linear combinations might not be enough).
First thing I did that gave me some hope was write the taylor expansions of both of them and comparing them:
$$ \cos x = \sum^{\infty}_{n=0} \frac{(-1)^n x^{2n}}{ (2n)!}$$
$$ e^{-x^2} = \sum^{\infty}_{n=0} \frac{(-x^2)^n}{n!} = \sum^{\infty}_{n=0} \frac{ (-1)^n x^{2n} }{n!}$$
apart from the denominator, the two power series are nearly identical! However, what worries me is that the factorial function is not easy (for me) to manipulate. Another great thing is that both functions are even, which is definitively great news!
Something else that worries me (about this approximation) is that they behave very differently in the tail ends of each other. For example, the Gaussian function dies off to towards the of the function while the cosine does not and instead oscillates (which is kind of a surprising difference if you only consider their power series, I wouldn't have guessed that difference, which is a very bid difference).
Something else that again gives me some hope about this approximation is the if you plot both $e^{-x^2}$ and $\cos x$, you get:

which even though they are not identical, at least for a bounded interval/domain, look extremely similar! Maybe one could tweak the parameters of one or the other and hopefully get something that might be considered "close" to each other.
So I I was thinking two direction that might be interesting to explore:


*

*An approximation on a bounded interval

*An approximation using an infinite series of $e^{-x^2}$ (that might be necessary to reflect on the x-axis to mirror the trough of the wave).


In fact, it might be possible to solve this issue by solving first an approximation of the crest of the cosine using  tweeked version of $e^{-x^2}$ and then, using that solution, do an infinite summation of that is reflected on the x-axis. T0 make things more clear, what I kind of had in mind with linear combinations was the following formula:
$$\sum_{k} c_k e^{- \| x - w_k\|^2}$$
with $w_k$ as the movable centers because we might need to center them at the troughs and crests of the cosines. I am open to different tweet suggestions of this (for example, an improvement could be to including a precision $\beta_k$ or a standard deviation $\sigma_k$ on the exponent to adjust the widths to match the cosine better).
I wasn't exactly sure if these were good ideas or if there were maybe better ways to approximate a cosine with $e^{-x^2}$, but I'd love to hear any ideas if people have better suggestions or know how to proceed (rigorously) with the ones I suggested.
 A: It would perhaps be easier to answer if you told us what your purpose with the approximation is.
I'll take a guess, since I had this in mind when I found the post. The cosine convolution is useful for doing diffuse lighting using environment maps. The (spherical) environment map of the lights is convolved with half a period of the cosine, covering a hemisphere of the map. The resulting map is indexed by the surface normal vectors. Computing the cosine convolution is very time consuming. Computing the Gaussian convolution is much quicker, because of the separable kernel. The idea may be to compute a number of Gaussian convolutions, then sum them to approximate the cosine convolution.
A: Let us restrict everything to a fixed closed and bounded interval $I$ - which interval is chosen doesn't matter.
Let's say a Gaussian is any function on $I$ of the form $C e^{-(x-a)^2}$.  Note that the product of two Gaussians is again a Gaussian:
$$C_1 e^{-(x-a_1)^2} C_2 e^{-(x-a_2)^2} = C_1 C_2 e^{-(x-a_1)^2 - (x-a_2)^2}$$
The exponent $-(x - a_1)^2 - (x - a_2)^2$ can be expressed in the form $-(x - \frac{a_1 + a_2}{2})^2 + D$ by completing the square, so we get a function of the form
$$C_1 C_2 e^D e^{-(x - \frac{a_1 + a_2}{2})^2}$$
as desired.
So consider the set $A$ of all finite linear combinations of Gaussians.  This set is closed under addition, and the computation above shows that it is also closed under multiplication.  In other words, it is a subalgebra of $C(I)$.  This subalgebra has two additional properties:


*

*$A$ is nonvanishing: there is no point $a \in I$ at which every function in $A$ vanishes (take the Gaussian centered at $a$, for instance)

*$A$ separates points: given $a_1$ and $a_2$ in $I$, there is a function $f \in A$ such that $f(a_1) \neq f(a_2)$ (take the Gaussian centered at $a_1$, for instance)


According to the Stone-Weierstrass theorem, $A$ is dense in $C(I)$ and hence every function in $C(I)$, including $\cos(x)$, can be approximated arbitrarily well in the uniform norm by finite linear combinations of Gaussians.

Of course, this doesn't really tell you how to compute an approximation.  This is bound to be a bit tricky, but one idea is to imitate the theory of Fourier series.  To begin, extract a subalgebra $A'$ of $A$ by restricting to Gaussians centered at a rational number $a$.  (Actually, by the formula for the product of two Gaussians above you could use dyadic rationals if you want - this might make some computations easier.)  With some slightly more delicate analysis you can show that $A'$ is also dense in $C(I)$.
Choose an enumeration $a_n$ of the rationals (or dyadic rationals).  Using the Gram-Schmidt algorithm you can then construct a sequence of functions $f_n$ in $A'$ with the following properties:


*

*The set $\{f_n\}$ is $L^2$-orthonormal, meaning the inner product of $f_m$ with $f_n$ is $1$ if $m = n$ and zero otherwise

*Each $f_n$ is in the span of $\{e^{-(x-a_1)^2}, \ldots, e^{-(x-a_n)^2}\}$


Using this orthonormal system of linear combinations of Gaussians you can then compute an explicit approximation $\sum_n c_n f_n$ where $c_n$ is the $L^2$-inner product of cosine with $f_n$.  This series will converge in the $L^2$ sense to cosine, and my guess is that it converges uniformly as well, but this would be much harder to prove (and it could conceivably depend on the chosen enumeration $a_n$).
