See: http://www.ies.co.jp/math/java/trig/graphFourier/graphFourier.html Example: a simple Fourier series We now use the formulae above to give a Fourier series expansion of a very simple function. Consider a sawtooth function (as depicted in the figure): f(x) = x, \quad \mathrm{for} \quad -\pi < x < \pi, f(x + 2\pi) = f(x), \quad \mathrm{for} \quad -\infty < x < \infty. In this case, the Fourier coefficients are given by \begin{align} a_n &{} = \frac{1}{\pi}\int_{-\pi}^{\pi}x \cos(nx)\,dx = 0. \\ b_n &{}= \frac{1}{\pi}\int_{-\pi}^{\pi} x \sin(nx)\, dx = 2\frac{(-1)^{n+1}}{n}.\end{align} And therefore: \begin{align} f(x) &= \frac{a_0}{2} + \sum_{n=1}^{\infty}\left[a_n\cos\left(nx\right)+b_n\sin\left(nx\right)\right] \\ &=2\sum_{n=1}^{\infty}\frac{(-1)^{n+1}}{n} \sin(nx), \quad \mathrm{for} \quad -\infty < x < \infty . \;\;\; (*) \end{align} In general: FourierSeriesExamples A Fourier series is an expansion of a periodic function f(x)in terms of an infinite sum of sines and cosines. Fourier series make use of the orthogonality relationships of the sine and cosine functions. The computation and study of Fourier series is known as harmonic analysis and is extremely useful as a way to break up an arbitrary periodic function into a set of simple terms that can be plugged in, solved individually, and then recombined to obtain the solution to the original problem or an approximation to it to whatever accuracy is desired or practical. Examples of successive approximations to common functions using Fourier series are illustrated above. In particular, since the superposition principle holds for solutions of a linear homogeneous ordinary differential equation, if such an equation can be solved in the case of a single sinusoid, the solution for an arbitrary function is immediately available by expressing the original function as a Fourier series and then plugging in the solution for each sinusoidal component. In some special cases where the Fourier series can be summed in closed form, this technique can even yield analytic solutions. Any set of functions that form a complete orthogonal system have a corresponding generalized Fourier series analogous to the Fourier series. For example, using orthogonality of the roots of a Bessel function of the first kind gives a so-called Fourier-Bessel series. The computation of the (usual) Fourier series is based on the integral identities int_(-pi)^pisin(mx)sin(nx)dx = pidelta_(mn) (1) int_(-pi)^picos(mx)cos(nx)dx = pidelta_(mn) (2) int_(-pi)^pisin(mx)cos(nx)dx = 0 (3) int_(-pi)^pisin(mx)dx = 0 (4) int_(-pi)^picos(mx)dx = 0 (5) for m,n!=0, where delta_(mn)is the Kronecker delta. Using the method for a generalized Fourier series, the usual Fourier series involving sines and cosines is obtained by taking f_1(x)=cosxand f_2(x)=sinx. Since these functions form a complete orthogonal system over [-pi,pi], the Fourier series of a function f(x)is given by f(x)=1/2a_0+sum_(n=1)^inftya_ncos(nx)+sum_(n=1)^inftyb_nsin(nx), (6) where a_0 = 1/piint_(-pi)^pif(x)dx (7) a_n = 1/piint_(-pi)^pif(x)cos(nx)dx (8) b_n = 1/piint_(-pi)^pif(x)sin(nx)dx (9) and n=1, 2, 3, .... Note that the coefficient of the constant term a_0has been written in a special form compared to the general form for a generalized Fourier series in order to preserve symmetry with the definitions of a_nand b_n. A Fourier series converges to the function f^_(equal to the original function at points of continuity or to the average of the two limits at points of discontinuity) f^_={1/2[lim_(x->x_0^-)f(x)+lim_(x->x_0^+)f(x)] for -pi-pi^+)f(x)+lim_(x->pi_-)f(x)] for x_0=-pi,pi if the function satisfies so-called Dirichlet conditions. FourierSeriesSquareWave As a result, near points of discontinuity, a "ringing" known as the Gibbs phenomenon, illustrated above, can occur. For a function f(x)periodic on an interval [-L,L]instead of [-pi,pi], a simple change of variables can be used to transform the interval of integration from [-pi,pi]to [-L,L]. Let x = (pix^')/L (11) dx = (pidx^')/L. (12) Solving for x^'gives x^'=Lx/pi, and plugging this in gives f(x^')=1/2a_0+sum_(n=1)^inftya_ncos((npix^')/L)+sum_(n=1)^inftyb_nsin((npix^')/L). (13) Therefore, a_0 = 1/Lint_(-L)^Lf(x^')dx^' (14) a_n = 1/Lint_(-L)^Lf(x^')cos((npix^')/L)dx^' (15) b_n = 1/Lint_(-L)^Lf(x^')sin((npix^')/L)dx^'. (16) Similarly, the function is instead defined on the interval [0,2L], the above equations simply become a_0 = 1/Lint_0^(2L)f(x^')dx^' (17) a_n = 1/Lint_0^(2L)f(x^')cos((npix^')/L)dx^' (18) b_n = 1/Lint_0^(2L)f(x^')sin((npix^')/L)dx^'. (19) In fact, for f(x)periodic with period 2L, any interval (x_0,x_0+2L)can be used, with the choice being one of convenience or personal preference (Arfken 1985, p. 769). The coefficients for Fourier series expansions of a few common functions are given in Beyer (1987, pp. 411-412) and Byerly (1959, p. 51). One of the most common functions usually analyzed by this technique is the square wave. The Fourier series for a few common functions are summarized in the table below. function f(x) Fourier series Fourier series--sawtooth x/(2L) 1/2-1/pisum_(n=1)^(infty)1/nsin((npix)/L) wave Fourier series--square 2[H(x/L)-H(x/L-1)]-1 4/pisum_(n=1,3,5,...)^(infty)1/nsin((npix)/L) wave Fourier series--triangle T(x) 8/(pi^2)sum_(n=1,3,5,...)^(infty)((-1)^((n-1)/2))/(n^2)sin((npix)/L) wave If a function is even so that f(x)=f(-x), then f(x)sin(nx)is odd. (This follows since sin(nx)is odd and an even function times an odd function is an odd function.) Therefore, b_n=0for all n. Similarly, if a function is odd so that f(x)=-f(-x), then f(x)cos(nx)is odd. (This follows since cos(nx)is even and an even function times an odd function is an odd function.) Therefore, a_n=0for all n. The notion of a Fourier series can also be extended to complex coefficients. Consider a real-valued function f(x). Write f(x)=sum_(n=-infty)^inftyA_ne^(inx). (20) Now examine int_(-pi)^pif(x)e^(-imx)dx = int_(-pi)^pi(sum_(n=-infty)^(infty)A_ne^(inx))e^(-imx)dx (21) = sum_(n=-infty)^(infty)A_nint_(-pi)^pie^(i(n-m)x)dx (22) = sum_(n=-infty)^(infty)A_nint_(-pi)^pi{cos[(n-m)x]+isin[(n-m)x]}dx (23) = sum_(n=-infty)^(infty)A_n2pidelta_(mn) (24) = 2piA_m, (25) so A_n=1/(2pi)int_(-pi)^pif(x)e^(-inx)dx. (26) The coefficients can be expressed in terms of those in the Fourier series A_n = 1/(2pi)int_(-pi)^pif(x)[cos(nx)-isin(nx)]dx (27) = {1/(2pi)int_(-pi)^pif(x)[cos(nx)+isin(nx)]dx n<0; 1/(2pi)int_(-pi)^pif(x)dx n=0; (28) 1/(2pi)int_(-pi)^pif(x)[cos(nx)-isin(nx)]dx n>0 (29) = {1/2(a_n+ib_n) for n<0; 1/2a_0 for n=0; 1/2(a_n-ib_n) for n>0. (30) For a function periodic in [-L/2,L/2], these become f(x) = sum_(n=-infty)^(infty)A_ne^(i(2pinx/L)) (31) A_n = 1/Lint_(-L/2)^(L/2)f(x)e^(-i(2pinx/L))dx. (32) These equations are the basis for the extremely important Fourier transform, which is obtained by transforming A_nfrom a discrete variable to a continuous one as the length L->infty. SEE ALSO: Complete Set of Functions, Dirichlet Fourier Series Conditions, Fourier-Bessel Series, Fourier Cosine Series, Fourier-Legendre Series, Fourier Series--Power, Fourier Series--Sawtooth Wave, Fourier Series--Semicircle, Fourier Series--Square Wave, Fourier Series--Triangle Wave, Fourier Sine Series, Fourier Transform, Generalized Fourier Series, Gibbs Phenomenon, Harmonic Addition Theorem, Harmonic Analysis, Lacunary Fourier Series, Lebesgue Constants, Power Spectrum, Riesz-Fischer Theorem, Simple Harmonic Motion, Superposition Principle REFERENCES: Arfken, G. "Fourier Series." Ch. 14 in Mathematical Methods for Physicists, 3rd ed. Orlando, FL: Academic Press, pp. 760-793, 1985. Askey, R. and Haimo, D. T. "Similarities between Fourier and Power Series." Amer. Math. Monthly 103, 297-304, 1996. Beyer, W. H. (Ed.). CRC Standard Mathematical Tables, 28th ed. Boca Raton, FL: CRC Press, 1987. Brown, J. W. and Churchill, R. V. Fourier Series and Boundary Value Problems, 5th ed. New York: McGraw-Hill, 1993. Byerly, W. E. An Elementary Treatise on Fourier's Series, and Spherical, Cylindrical, and Ellipsoidal Harmonics, with Applications to Problems in Mathematical Physics. New York: Dover, 1959. Carslaw, H. S. Introduction to the Theory of Fourier's Series and Integrals, 3rd ed., rev. and enl. New York: Dover, 1950. Davis, H. F. Fourier Series and Orthogonal Functions. New York: Dover, 1963. Dym, H. and McKean, H. P. Fourier Series and Integrals. New York: Academic Press, 1972. Folland, G. B. Fourier Analysis and Its Applications. Pacific Grove, CA: Brooks/Cole, 1992. Groemer, H. Geometric Applications of Fourier Series and Spherical Harmonics. New York: Cambridge University Press, 1996. Körner, T. W. Fourier Analysis. Cambridge, England: Cambridge University Press, 1988. Körner, T. W. Exercises for Fourier Analysis. New York: Cambridge University Press, 1993. Krantz, S. G. "Fourier Series." §15.1 in Handbook of Complex Variables. Boston, MA: Birkhäuser, pp. 195-202, 1999. Lighthill, M. J. Introduction to Fourier Analysis and Generalised Functions. Cambridge, England: Cambridge University Press, 1958. Morrison, N. Introduction to Fourier Analysis. New York: Wiley, 1994. Sansone, G. "Expansions in Fourier Series." Ch. 2 in Orthogonal Functions, rev. English ed. New York: Dover, pp. 39-168, 1991. Weisstein, E. W. "Books about Fourier Transforms." http://www.ericweisstein.com/encyclopedias/books/FourierTransforms.html. Whittaker, E. T. and Robinson, G. "Practical Fourier Analysis." Ch. 10 in The Calculus of Observations: A Treatise on Numerical Mathematics, 4th ed. New York: Dover, pp. 260-284, 1967. CITE THIS AS: Weisstein, Eric W. "Fourier Series." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/FourierSeries.html Maple code: Four:=proc(N,f) local x,a,b,n,i,xxx,M; a:=(f,n)->1/Pi*evalf(Int(f(x)*cos(n*x),x=-Pi..Pi)); b:=(f,n)->1/Pi*evalf(Int(f(x)*sin(n*x),x=-Pi..Pi)); if N mod 2 = 1 then M:=(N-1)/2; xxx:=a(f,0)/2+sum(a(f,i)*cos(i*x)+b(f,i)*sin(i*x),i=1..M); else M:=(N-2)/2; xxx:=a(f,0)/2+sum(a(f,i)*cos(i*x)+b(f,i)*sin(i*x),i=1..M)+a(f,N/2)*cos(N/2*x); fi; unapply(xxx,x) end; example: Four(5,exp)(z); 11.54873936/Pi-3.676077913*cos(z)+3.676077910*sin(z)+1.470431167*cos(2.*z)-2.940862328*sin(2.*z)