Every function can be represented as a Fourier Series - but why?

I can't really find a good answer to this question - the statement just seems to be assumed everywhere I look. Admittedly, I am not too well versed in the topic but I am an engineer and can understand Fourier Transforms up to a point. But in researching the JPEG algorithm I am led back to the very beginning.

The question seems to be related to the convergence of a Fourier series to a function, but I'm not so concerned with IF a series converges to a function then I am concerned with how Joseph Fourier made this breakthrough in the first place. Did he just think about it and then say it was so? Is there a mathematical proof that says that every periodic function can be represented by sines and cosines?

(Also, if possible, ELI5)

• Not every periodic function, but every sufficiently nice periodic function. – Hans Lundmark Jul 29 '18 at 7:29
• Thanks for the clarification - you are correct, of course. That kind of makes the question even harder. How did our friend Joe Fou know that the Fourier Series holds true for only certain functions? – squeegene Jul 29 '18 at 7:32
• I don't think he did, that was a later realization. – Hans Lundmark Jul 29 '18 at 7:32
• – Hans Lundmark Jul 29 '18 at 7:33
• Thanks for the extra resources - perhaps I should close this question – squeegene Jul 29 '18 at 7:43

In the mid 1700's, Bernoulli was studying the problem of a vibrating string, and he had proposed a general solution in terms of standing waves. Euler realized that, if Bernoulli's solution were to be general, it would be necessary to be able to expand the initial displacement function of the string in a trigonometric series, which is now called the Fourier series: $$f \sim \frac{a_0}{2}+a_1\cos(x)+b_1\sin(x)+a_2\cos(2x)+b_2\sin(2x)+\cdots.$$ Remarkably, Clairaut and Euler discovered the orthogonality conditions that are needed to isolate the coefficients in such an expansion. They noticed that if you multiply any two of the functions $1,\cos(x),\sin(x),\cos(2x),\sin(2x),\cdots$ and integrate over $[0,2\pi]$, you get $0$ for the answer unless the two functions are the same. And that's how they first determined what the coefficients would have to be, if such an expansion were possible. Euler's opinion was that such an expansion could not be generally possible; instead he thought this represented a restriction on the possible initital displacement functions $f$ that could be used to solve the vibrating string problem in this manner.