
You may well be wondering how I got the relative amplitudes of the sine waves to produce our square wave approximation. Well, that's what we're going to dive into here. There are two ways of doing it: standard solutions from HLT, and deriving it from Fourier integrals.
An important point to note, before you dive into the maths, is the difference between odd and even functions. For odd functions, on the other side of the y-axis, the function is inverted. That is to say:

sin is an odd function. So, from this, you should be able to see that an odd function is made up of sin functions only. And any combination of sin functions will produce odd functions.

Similarly, cos is an even function (mirrored about the y-axis), and so combinations of cos functions produce even functions.
This is all stated rather obliquely in HLT p11. Of course, some functions are neither wholly odd nor even: they are asymmetric. HLT miserably fails to produce any graphical examples of this, but it should (I hope) be fairly obvious that asymmetric functions are made up of both sin and cos functions:

Okay, so you have an arbitrary function which isn't in HLT. Or you're in an exam and you want to prove from first principles.
What we're hoping for is a series of the form:
or
where ai and bi are constants we can find. From the previous section's discussion of odd and even functions, you should be able to see that ai will be zero for odd functions, and bi zero for even functions.
For ease of reference, I'm going to tell you the answer to the question now, and then explain it:
Why? It has to do with the orthogonality of sin and cos functions. I refuse to talk much about this; suffice it to say that, for integer i and j:
Obviously, therefore, constituent cos and sin terms will pair up with the multiplying cos and sin terms by integrating over a single period. (If you don't believe me, try it, or see my explanation.) You are then left with just one term multiplying each: corresponding to ai (or bi if you're doing sines). So, if you just integrate this original function lots of times, each time multiplying it by cos(iωt), with i going up from 0, you will get the coefficients of the cos terms by:
which then yields the equation above for ai and bi.
Easy-peasy lemon squeezy. So to speak. You can see these equations in HLT.
Alert readers will say, Hang on - haven't we seen combinations of sin and cos functions before?
Well, combinations of sin and cos functions were found in 2nd order differential equations last year, and you may remember we got them from complex exponentials:
So, if we fit these into our expression for the Fourier series, we get a new one in terms of j, with complex exponentials and complex coefficients ck. Oh joy.
where
Notice that now, instead of starting at zero, our counter starts at minus infinity. So, in summary, you can get a complex Fourier series from a real one quite easily. Or you can get c k straight away:
If you refer to HLT p10, you should be able to see the function X(ω) which looks remarkably similar to our expression for c k earlier. This will lead us into the next big area: Fourier transforms. But for now: you can transform any periodic function (that you can integrate). Even better: easy functions like simple combinations of sin and cos functions you can transform immediately into a Fourier series. It shouldn't take too much effort to imagine doing it for linear combinations of complex exponentials either. Wahey!
So, because this is so easy to do, let's have some really simple examples.
The easy way of obtaining the Fourier series of some functions is to reduce them to a sum of sine and cosine terms, then just read off the coefficients. For example, take the function
This is equal to
This is a simple Fourier series, with ω0 = 200, a1 = 1, and b1 = j. Generating the complex coefficients is even easier: c1 = 1 (from the coefficient of ejωt).
Where did I get ω0 from? The answer is quite simple: in cases like this, it's the lowest angular frequency expressed; in this case 200. In general, however, ω0 = 2 π / T, where T is the minimum time between repeats of the function (period).
To illustrate this, let's take an easy function:
ω0 = 4, a1 = 1, and b2 = 1. (The function repeats after π / 2, giving ω0).
Our last example will demonstrate the integration method of determining coefficients. The function I'm going to transform looks like this:

It has period 2, and x (t) = e -t for |t|<1.
And at this point, the Fourier analysis is finished! We now have an expression for each of the coefficients of the complex Fourier series, and the rest is just algebraic simplification.
Knowing that ωT = 2π, and T = 2, we get ω = π, and:

If you work out e - jkπ and e jkπ you will notice that:

for integral k. Thus, this equation becomes:

Note that although the ck terms are complex, the series results in a wholly real function x(t). This is because:

Terms on each side of 0 are conjugate, and so the complex parts will cancel.
Due to certain geological conditions, a road in Africa develops an uneven surface depth governed by the equation:

i) Show that this can be represented by a Fourier series containing only odd harmonic sine terms, and find an expression for the coefficients.
Since the surface is periodic, and has odd half- and even quarter-wave symmetry, we can conclude that it can be represented by such a series.
To find the Fourier coefficients, we must perform the integral:

If ω = 2π/L, this yields

where φ = π/4.
Now, the Fourier analysis is done.
Next, we'll talk about non-periodic functions and the Fourier transform.