The Fourier series of a function f(x) defined on the interval (−L,L) is given by: f(x)=2a0+∑n=1∞(ancos(Lnπx)+bnsin(Lnπx)) where the Fourier coefficients are given by:
a0=L1∫−LLf(x)dx an=L1∫−LLf(x)cos(Lnπx)dx bn=L1∫−LLf(x)sin(Lnπx)dx In our case, L=2. Let's calculate the coefficients: a0=21∫−22f(x)dx=21(∫−202dx+∫02xdx)=21([2x]−20+[2x2]02)=21((0−(−4))+(24−0))=21(4+2)=26=3 an=21∫−22f(x)cos(2nπx)dx=21(∫−202cos(2nπx)dx+∫02xcos(2nπx)dx) ∫−202cos(2nπx)dx=2[nπ2sin(2nπx)]−20=nπ4(sin(0)−sin(−nπ))=nπ4(0−0)=0 ∫02xcos(2nπx)dx=[nπ2xsin(2nπx)+n2π24cos(2nπx)]02=(nπ4sin(nπ)+n2π24cos(nπ))−(0+n2π24cos(0))=0+n2π24(−1)n−n2π24=n2π24((−1)n−1) an=21(0+n2π24((−1)n−1))=n2π22((−1)n−1) bn=21∫−22f(x)sin(2nπx)dx=21(∫−202sin(2nπx)dx+∫02xsin(2nπx)dx) ∫−202sin(2nπx)dx=2[−nπ2cos(2nπx)]−20=−nπ4(cos(0)−cos(−nπ))=−nπ4(1−(−1)n) ∫02xsin(2nπx)dx=[−nπ2xcos(2nπx)+n2π24sin(2nπx)]02=(−nπ4cos(nπ)+n2π24sin(nπ))−(0+0)=−nπ4(−1)n bn=21(−nπ4(1−(−1)n)−nπ4(−1)n)=21(−nπ4+nπ4(−1)n−nπ4(−1)n)=−nπ2 Therefore, the Fourier series is:
f(x)=23+∑n=1∞(n2π22((−1)n−1)cos(2nπx)−nπ2sin(2nπx))