Write down the function to be analyzed. Write it in the form f(x) -- that is, a function of the variable "x." For example, you may want to perform a Fourier analysis on the function that represents a line of slope 1 passing through the origin. Write such a function as f(x) = x. Confirm that the function has integrability and that the x-value in your function can be bound between negative pi and pi.
Multiply your function by cos(kx) and call it A(x). Here, "k" is a constant and should be left as is. For example, if your function is f(x) = x, this step would require you to create the new function xcos(kx) using multiplication.
Calculate a0 by letting k=0 and integrating A(x) from negative pi to pi and divide by pi. Perform integration according to standard calculus rules. The solution is the a0 coefficient. For the example, the integral of xcos(kx) from negative pi to pi is 0. Thus, a0=0.
Calculate ak. Leave k as is, integrate A(x) from negative pi to pi and divide by pi. Perform integration according to standard calculus rules. The solution is the ak coefficient. For the example, the integral of xcos(kx) is [xsin(kx)/k + cos(kx)/k^2]. Evaluated from negative pi to pi, this equates to zero. Thus ak=0.
Multiply your function by sin(kx) and call it B(x). Here, "k" is again a constant and should be left as is. For the function f(x) = x, this step would require you to create the new function xsin(kx) using multiplication. So, for the example, let B(x)=xsin(kx).
Calculate bk by integrating B(x) from A(x) from negative pi to pi and divide by pi. Perform integration according to standard calculus rules. The solution is the bk coefficient. For the example, the integral of xsin(kx) is [-xcos(kx)/k + sin(kx)/k^2]. Evaluated from negative pi to pi, this equates to (-pi)^(k+1)*(2/k). After dividing by pi, this becomes (-1)^(k+1)*(2/k). Thus bk=(-1)^(k+1)*(2/k).
Write the function in terms of its Fourier series. This is the result of the Fourier analysis. The formula is f(x) = a0/2 + sigma(ak*cos(kx)+bk*sin(kx)) from k=1 to k=infinity. For the example, the Fourier analysis yields x = 2(sin(x) - sin(2x)/2 + sin(3x)/3 - ...).