To recognize what they are, we write out the function f(x)=|f⟩{\displaystyle f(x)=|f\rangle } in terms of a basis gn. {\displaystyle g_{n}. } In order for this basis to be useful, it must be orthonormal so that ⟨gn|gm⟩=δnm,{\displaystyle \langle g_{n}|g_{m}\rangle =\delta {nm},} the Kronecker delta that equals 1{\displaystyle 1} if n=m{\displaystyle n=m} and 0{\displaystyle 0} otherwise. The expression below simply means that we are projecting f{\displaystyle f} onto gn. {\displaystyle g{n}. } |f⟩=∑n|gn⟩⟨gn|f⟩{\displaystyle |f\rangle =\sum {n}|g{n}\rangle \langle g_{n}|f\rangle } For functions defined on the interval [−L,L],{\displaystyle [-L,L],} we define the following inner product. Notice that this inner product is normalized. The ∗{\displaystyle {}^{}} symbol denotes the complex conjugate. ⟨gn|f⟩=1L∫−LLgn(x)∗f(x)dx{\displaystyle \langle g_{n}|f\rangle ={\frac {1}{L}}\int {-L}^{L}g{n}(x)^{}f(x)\mathrm {d} x} The functions cosnπxL{\displaystyle \cos {\frac {n\pi x}{L}}} and sinnπxL{\displaystyle \sin {\frac {n\pi x}{L}}} comprise the Fourier basis. With this in mind, we may write the Fourier coefficients below. When one substitutes f(x){\displaystyle f(x)} with an element of the Fourier basis, the coefficient goes to unity. Hence the basis elements under this inner product form an orthonormal set. an=1L∫−LLf(x)cosnπxLdx{\displaystyle a_{n}={\frac {1}{L}}\int {-L}^{L}f(x)\cos {\frac {n\pi x}{L}}\mathrm {d} x} bn=1L∫−LLf(x)sinnπxLdx{\displaystyle b{n}={\frac {1}{L}}\int {-L}^{L}f(x)\sin {\frac {n\pi x}{L}}\mathrm {d} x} What is the interpretation of the constant term a0,{\displaystyle a{0},} and why do we need an extra 12{\displaystyle {\frac {1}{2}}} in the expression? This expression is in fact the average value of f(x){\displaystyle f(x)} over the interval. (If the function is periodic, then it is the average value of the function over the entire domain. ) The extra 12{\displaystyle {\frac {1}{2}}} is there because of the boundaries and compensates for the fact that we are integrating over an interval with length 2L. {\displaystyle 2L. } a02=12L∫−LLf(x)dx{\displaystyle {\frac {a_{0}}{2}}={\frac {1}{2L}}\int _{-L}^{L}f(x)\mathrm {d} x}
an=1L∫−LLf(x)cosnπxLdx{\displaystyle a_{n}={\frac {1}{L}}\int {-L}^{L}f(x)\cos {\frac {n\pi x}{L}}\mathrm {d} x} bn=1L∫−LLf(x)sinnπxLdx{\displaystyle b{n}={\frac {1}{L}}\int _{-L}^{L}f(x)\sin {\frac {n\pi x}{L}}\mathrm {d} x}
f(x)=x2−2x+1: [−1,1]{\displaystyle f(x)=x^{2}-2x+1:\ [-1,1]}
For our function, x2+1{\displaystyle x^{2}+1} is even and −2x{\displaystyle -2x} is odd. This means that bn=0{\displaystyle b_{n}=0} for x2+1{\displaystyle x^{2}+1} and an=0{\displaystyle a_{n}=0} for −2x. {\displaystyle -2x. }
a0=∫−11(x2+1)dx=83{\displaystyle a_{0}=\int _{-1}^{1}(x^{2}+1)\mathrm {d} x={\frac {8}{3}}}
an=∫−11(x2+1)cosnπxdx=4(−1)nn2π2{\displaystyle a_{n}=\int {-1}^{1}(x^{2}+1)\cos n\pi x\mathrm {d} x={\frac {4(-1)^{n}}{n^{2}\pi ^{2}}}} bn=∫−11−2xsinnπxdx=4(−1)nnπ{\displaystyle b{n}=\int _{-1}^{1}-2x\sin n\pi x\mathrm {d} x={\frac {4(-1)^{n}}{n\pi }}}
x2−2x+1=43+∑n=1∞[4(−1)nn2π2cosnπx+4(−1)nnπsinnπx]{\displaystyle x^{2}-2x+1={\frac {4}{3}}+\sum _{n=1}^{\infty }\left[{\frac {4(-1)^{n}}{n^{2}\pi ^{2}}}\cos n\pi x+{\frac {4(-1)^{n}}{n\pi }}\sin n\pi x\right]} The image shows the Fourier series up to n=3,{\displaystyle n=3,} n=15,{\displaystyle n=15,} and n=100. {\displaystyle n=100. } We can clearly see the convergence here, as well as the overshoots near the boundaries that do not seem to vanish at higher n. {\displaystyle n. } This is the Gibbs phenomenon, which is the result of the failure of the series to converge uniformly on the prescribed interval.