By definition of Fourier series: :$\displaystyle \map f x \sim \frac {a_0} 2 + \sum_{n \mathop = 1}^\infty \paren {a_n \cos n x + b_n \sin n x}$ where: {{begin-eqn}} {{eqn | l = a_n       | r = \dfrac 1 \pi \int_0^{2 \pi} \map f x \cos n x \rd x }} {{eqn | l = b_n       | r = \dfrac 1 \pi \int_0^{2 \pi} \map f x \sin n x \rd x }} {{end-eqn}} for all $n \in \Z_{>0}$. Thus: {{begin-eqn}} {{eqn | l = a_0       | r = \frac 1 \pi \int_0^{2 \pi} \map f x \rd x       | c = Cosine of Zero is One }} {{eqn | r = \frac 1 \pi \int_0^\pi \paren {x - \pi}^2 \rd x + \frac 1 \pi \int_\pi^{2 \pi} \pi^2 \rd x       | c =  }} {{eqn | r = \frac 1 \pi \int_0^\pi \paren {x^2 + 2 \pi x - \pi^2} \rd x + \frac 1 \pi \bigintlimits {\pi^2 x} \pi {2 \pi}       | c = Primitive of Constant }} {{eqn | r = \frac 1 \pi \intlimits {\frac {x^3} 3 + \pi x^2 - \pi^2 x} 0 \pi + \frac 1 \pi \bigintlimits {\pi^2 x} \pi {2 \pi}       | c = Primitive of Power }} {{eqn | r = \frac 1 \pi \paren {\paren {\frac {\pi^3} 3 + \pi^3 - \pi^3} - \paren {\frac {0^3} 3 + \pi \times 0^2 - \pi^2 \times 0} + \paren {\pi^2 \times 2 \pi} - \paren {\pi^3} }       | c =  }} {{eqn | r = \frac {\pi^2} 3 + 2 \pi^2 - \pi^2       | c =  }} {{eqn | r = \frac {4 \pi^2} 3       | c =  }} {{end-eqn}} {{qed|lemma}} For $n > 0$: {{begin-eqn}} {{eqn | l = a_n       | r = \frac 1 \pi \int_0^{2 \pi} \map f x \cos n x \rd x       | c =  }} {{eqn | r = \frac 1 \pi \int_0^\pi \paren {x - \pi}^2 \cos n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} \pi^2 \cos n x \rd x       | c = Definition of $f$ }} {{eqn | r = \frac 1 \pi \int_0^\pi \paren {x^2 - 2 \pi x + \pi^2} \cos n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} \pi^2 \cos n x \rd x       | c =  }} {{eqn | r = \frac 1 \pi \int_0^\pi x^2 \cos n x \rd x - 2 \int_0^\pi x \cos n x \rd x + \pi \int_0^\pi \cos n x \rd x + \pi \int_\pi^{2 \pi} \cos n x \rd x       | c = Linear Combination of Integrals }} {{end-eqn}} Splitting this up into bits: {{begin-eqn}} {{eqn | o =        | r = \pi \int_0^\pi \cos n x \rd x + \pi \int_\pi^{2 \pi} \cos n x \rd x       | c =  }} {{eqn | r = \pi \int_0^{2 \pi} \cos n x \rd x       | c = Sum of Integrals on Adjacent Intervals for Continuous Functions }} {{eqn | r = 0       | c = Integral over $2 \pi$ of $\cos n x$ }} {{end-eqn}} {{begin-eqn}} {{eqn | o =        | r = 2 \int_0^\pi x \cos n x \rd x       | c =  }} {{eqn | r = 2 \intlimits {\frac {\cos n x} {n^2} + \frac {x \sin n x} n} 0 \pi       | c = Primitive of $x \cos n x$ }} {{eqn | r = 2 \paren {\frac {\cos n \pi} {n^2} + \frac {\pi \sin n \pi} n} - 2 \paren {\frac {\cos 0} {n^2} + \frac {0 \sin 0} n}       | c =  }} {{eqn | r = \frac {2 \cos n \pi} {n^2} - \frac {2 \cos 0} {n^2}       | c = Sine of Multiple of Pi }} {{eqn | r = \paren {-1}^n \frac 2 {n^2} - \frac 2 {n^2}       | c = Cosine of Multiple of Pi }} {{end-eqn}} {{begin-eqn}} {{eqn | o =        | r = \frac 1 \pi \int_0^\pi x^2 \cos n x \rd x       | c =  }} {{eqn | r = \frac 1 \pi \intlimits {\frac {2 x \cos n x} {n^2} + \paren {\frac {x^2} n - \frac 2 {n^3} } \sin n x} 0 \pi       | c = Primitive of $x^2 \cos n x$ }} {{eqn | r = \frac 1 \pi \paren {\frac {2 \pi \cos n \pi} {n^2} + \paren {\frac {\pi^2} n - \frac 2 {n^3} } \sin n \pi} - \frac 1 \pi \paren {\frac {0 \cos 0} {n^2} + \paren {\frac 0 n - \frac 2 {n^3} } \sin 0}       | c =  }} {{eqn | r = \frac 1 \pi \frac {2 \pi \cos n \pi} {n^2}       | c = Sine of Multiple of Pi and removal of vanishing terms }} {{eqn | r = \paren {-1}^n \frac 2 {n^2}       | c = Cosine of Multiple of Pi }} {{end-eqn}} Reassembling $a_n$ from the remaining non-vanishing terms: {{begin-eqn}} {{eqn | l = a_n       | r = \paren {-1}^n \frac 2 {n^2} - \paren {-1}^n \frac 2 {n^2} + \frac 2 {n^2}       | c =  }} {{eqn | r = \frac 2 {n^2}       | c =  }} {{end-eqn}} {{qed|lemma}} Now for the $\sin n x$ terms: {{begin-eqn}} {{eqn | l = b_n       | r = \frac 1 \pi \int_0^{2 \pi} \map f x \sin n x \rd x       | c =  }} {{eqn | r = \frac 1 \pi \int_0^\pi \paren {x - \pi}^2 \sin n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} \pi^2 \sin n x \rd x       | c = Definition of $f$ }} {{eqn | r = \frac 1 \pi \int_0^\pi \paren {x^2 - 2 \pi x + \pi^2} \sin n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} \pi^2 \sin n x \rd x       | c =  }} {{eqn | r = \frac 1 \pi \int_0^\pi x^2 \sin n x \rd x - 2 \int_0^\pi x \sin n x \rd x + \pi \int_0^\pi \sin n x \rd x + \pi \int_\pi^{2 \pi} \sin n x \rd x       | c = Linear Combination of Integrals }} {{end-eqn}} Splitting this up into bits: {{begin-eqn}} {{eqn | o =        | r = \pi \int_0^\pi \sin n x \rd x + \pi \int_\pi^{2 \pi} \sin n x \rd x       | c =  }} {{eqn | r = \pi \int_0^{2 \pi} \sin n x \rd x       | c = Sum of Integrals on Adjacent Intervals for Continuous Functions }} {{eqn | r = 0       | c = Integral over $2 \pi$ of $\sin n x$ }} {{end-eqn}} {{begin-eqn}} {{eqn | o =        | r = 2 \int_0^\pi x \sin n x \rd x       | c =  }} {{eqn | r = 2 \intlimits {\frac {\sin n x} {n^2} - \frac {x \cos n x} n} 0 \pi       | c = Primitive of $x \sin n x$ }} {{eqn | r = 2 \paren {\frac {\sin n \pi} {n^2} - \frac {\pi \cos n \pi} n} - 2 \paren {\frac {\sin 0} {n^2} - \frac {0 \cos 0} n}       | c =  }} {{eqn | r = -\frac {2 \pi \cos n \pi} n       | c = Sine of Multiple of Pi and removal of vanishing terms }} {{end-eqn}} {{begin-eqn}} {{eqn | o =        | r = \frac 1 \pi \int_0^\pi x^2 \sin n x \rd x       | c =  }} {{eqn | r = \frac 1 \pi \intlimits {\frac {2 x \sin n x} {n^2} + \paren {\frac 2 {n^3} - \frac {x^2} n} \cos n x} 0 \pi       | c = Primitive of $x^2 \sin n x$ }} {{eqn | r = \frac 1 \pi \paren {\frac {2 \pi \sin n \pi} {n^2} + \paren {\frac 2 {n^3} - \frac {\pi^2} n} \cos n \pi} - \frac 1 \pi \paren {\frac {0 \sin 0} {n^2} + \paren {\frac 2 {n^3} - \frac {0^2} n} \cos 0}       | c =  }} {{eqn | r = \frac 1 \pi \paren {\paren {\frac 2 {n^3} - \frac {\pi^2} n} \cos n \pi} - \frac 1 \pi \paren {\frac 2 {n^3} \cos 0}       | c = Sine of Multiple of Pi and removal of vanishing terms }} {{eqn | r = \frac 2 {\pi n^3} \paren {\cos n \pi - 1} - \frac \pi n \cos n \pi       | c = Cosine of Zero is One and simplifying }} {{end-eqn}} Reassembling $b_n$ from the remaining non-vanishing terms: {{begin-eqn}} {{eqn | l = b_n       | r = \frac 2 {\pi n^3} \paren {\cos n \pi - 1} - \frac \pi n \cos n \pi - \paren {- \frac {2 \pi \cos n \pi} n}       | c =  }} {{eqn | r = \frac 2 {\pi n^3} \paren {\cos n \pi - 1} + \frac \pi n \cos n \pi       | c = simplifying }} {{eqn | r = \frac 2 {\pi n^3} \paren {\paren {-1}^n - 1} + \frac {\paren {-1}^n \pi} n       | c = Cosine of Multiple of Pi }} {{end-eqn}} {{qed|lemma}} Finally: {{begin-eqn}} {{eqn | l = \map f x       | o = \sim       | r = \frac {a_0} 2 + \sum_{n \mathop = 1}^\infty \paren {a_n \cos n x + b_n \sin n x}       | c =  }} {{eqn | r = \dfrac 1 2 \paren {\frac {4 \pi^2} 3} + \sum_{n \mathop = 1}^\infty \paren {\frac 2 {n^2} \cos n x + \paren {\frac 2 {\pi n^3} \paren {\paren {-1}^n - 1} + \frac {\paren {-1}^n \pi} n} \sin n x}       | c = substituting for $a_0$, $a_n$ and $b_n$ from above }} {{eqn | r = \frac {2 \pi^2} 3 + \sum_{n \mathop = 1}^\infty \paren {\frac {2 \cos n x} {n^2} + \paren {\frac {\paren {-1}^n \pi} n + \frac {2 \paren {\paren {-1}^n - 1} } {\pi n^3} } \sin n x}       | c = rearranging }} {{end-eqn}} {{qed}}