formula 1:
g(x) = a0 + a1×cos(x) + a2×cos(2x) + a3×cos(3x) + a4×cos(4x) + …
+ b1×sin(x) + b2×sin(2x) + b3×sin(3x) + b4×sin(4x) + …
To be technically correct, you should interleave the terms, giving one series.
Formula 2:
g(x) = a0 + b1×sin(x) + a1×cos(x) + b2×sin(2x) + a2×cos(2x) + …
Until we can prove otherwise, the order of terms might be important. For some coefficients, and some values of x, the series could be conditionally convergent.
If the a and b series in the first formulation converge, we can add the two series together to get the second formula. However, the second formula might converge, even when the subseries in formula 1 do not, so it's best to use formula 2.
For a rather trivial example, note that the constant function 17 has fourier coefficients [17,0,0,0,0,…], and the function 6+3×cos(x)+sin(2x) has coefficients [6,0,3,1,0,0,0…].
Other local rearrangements of formula 2 are equally valid, such as this one.
Formula 3:
g(x) = a0 + a1cos(x) + b1sin(x) + a2cos(2x) + b2sin(2x) + …
Note that formula 2 is uniformly convergent iff formula 3 is uniformly convergent. The proof is similar to the one referenced above, but we need to tweak it just a bit.
Given ε, find an n such that the partial sums in formula 2, independent of x, are within ¼ε of g(x). Now suppose, for some x and some k beyond n, a term t is at least ¾ε. Before t is brought in, the partial sum is within ¼ε of g(x), and the same holds after t is brought in. Yet t is simply too large, so we have a contradiction. The terms beyond n are bounded by ¾ε. Now consider a partial sum, from formula 3, beyond n. If the sum winds up on a pair boundary, the sum is the same as in formula 2, and we're ok. Otherwise, back up to the previous pair, which is within ¼ε of g(x), and apply the extra term, which is bounded by ¾ε. The sum is within ε of g(x), and we have uniform convergence.
We'll see this as we make other local rearrangements. If convergence is preserved, it's a good bet that uniform convergence is also preserved.
If the fourier series is defined at x, it attains the same value at x±2π. Thus the wave form repeats, all along the x axis, with period 2π.
Assume a set of coefficients leads to the function g(), which is defined everywhere, and assume the fourier series converges uniformly to g.
Let f be any of the orthogonal basis functions. We know that the series, multiplied by f, sums to g×f. Choose n so that the partial sum of fourier functions is within ε of g. In other words, the difference between g and this partial sum, or any subsequent partial sum, is bounded by ε, for any x. Multiply through by f, and the difference, the error term, is multiplied by f. Since f is bounded by 1, the difference can only get smaller. The series remains uniformly convergent, and can be integrated term by term. Since the basis is orthogonal, all the terms go away except for f. This gives us a formula for the fourier coefficients, as shown below.
ai = (∫ g×fi) over (∫ fi×fi)
The denominator is the integral of sin(nx)2, or the integral of cos(nx)2. These two functions are complementary, i.e. their sum is 1 for all x. And they are really the same function; one is a shifted version of the other. So each consumes half the area of the rectangle. In other words, the denominator becomes half of 2π, or π. So the formula looks like this.
ai = (∫ g×fi) over π
Remember that a0 is an exception.
a0 = (∫ g) over 2π
An n dimensional fourier series, like its one dimensional counterpart, could be conditionally convergent, so the order of terms is significant. A proper definition must prescribe the order.
Start with a0, the integral of g over (2π)n. After that, the series brings in the sines and cosines. For instance, in 2 dimensions we include sin(x), cos(x), sin(y), cos(y), and the four products therefrom. Next bring in sin(2x) and cos(2x), and this pair times sin(y) and cos(y), and sin(2y) and cos(2y), and this pair times sin(x) and cos(x), and the four way cross product of sin(2x) and cos(2x) with sin(2y) and cos(2y). Then bring in the third harmonics, then the fourth, and so on.
This construction can be generalized to higher dimensions. At each step, bring in the nth harmonics, in sine cosine pairs, times everything that has gone before. some variation is permitted, as long as you progress from low harmonics to high harmonics. We'll be more formal about prescribing an order when specific multi-dimensional examples arise.