Theorem: Fourier Series/Minus Pi over 0 to Pi, x minus Pi over Pi to 2 Pi

Let $\map f x$ be the real function defined on $\openint 0 {2 \pi}$ as:
:500pxthumbright$\map f x$ and its $7$th approximation
:<nowiki>$\map f x = \begin{cases}
-\pi & : 0 < x \le \pi \\
x - \pi & : \pi < x < 2 \pi \end{cases}$</nowiki>
Then its Fourier series can be expressed as:
{{begin-eqn}}
{{eqn | l = \map f x
      | o = \sim
      | r = -\frac \pi 4 + \frac 2 \pi \sum_{r \mathop = 0}^\infty \frac {\cos \paren {2 r + 1} x} {\paren {2 r + 1}^2} - \sum_{n \mathop = 1}^\infty \frac {2 - \paren {-1}^n \sin n x} n
      | c = 
}}
{{eqn | r = -\frac \pi 4 + \frac 2 \pi \paren {\cos x + \frac {\cos 3 x} 9 + \frac {\cos 5 x} {25} + \cdots} - 3 \paren {\sin x + \frac {\sin 3 x} 3 + \frac {\sin 5 x} 5 + \cdots} - \paren {\frac {\sin 2 x} 2 + \frac {\sin 4 x} 4 + \cdots}
      | c = 
}}
{{end-eqn}}

Proof:
By definition of Fourier series:
:$\ds \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 = \frac 1 \pi \int_0^{2 \pi} \map f x \cos n x \rd x
}}
{{eqn | l = b_n
      | r = \frac 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 -\pi \rd x + \frac 1 \pi \int_\pi^{2 \pi} \paren {x - \pi} \rd x
      | c = 
}}
{{eqn | r = -\int_0^\pi \rd x + \frac 1 \pi \int_\pi^{2 \pi} x \rd x - \int_\pi^{2 \pi} \rd x
      | c = Linear Combination of Definite Integrals
}}
{{eqn | r = -\int_0^{2 \pi} \rd x + \frac 1 \pi \int_\pi^{2 \pi} x \rd x
      | c = Sum of Integrals on Adjacent Intervals for Continuous Functions
}}
{{eqn | r = -\bigintlimits x 0 {2 \pi} + \frac 1 \pi \int_\pi^{2 \pi} x \rd x
      | c = Primitive of Constant
}}
{{eqn | r = -\paren {2 \pi - 0} + \frac 1 \pi \int_\pi^{2 \pi} x \rd x
      | c = 
}}
{{eqn | r = -2 \pi + \frac 1 \pi \paren {\intlimits {\frac {x^2} 2} \pi {2 \pi} }
      | c = Primitive of Power
}}
{{eqn | r = -2 \pi + \frac 1 \pi \paren {\frac {\paren {2 \pi}^2} 2 - \frac {\pi^2} 2}
      | c = 
}}
{{eqn | r = -2 \pi + 2 \pi - \frac \pi 2
      | c = 
}}
{{eqn | r = -\frac \pi 2
      | 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 {-\pi} \cos n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} \paren {x - \pi} \cos n x \rd x
      | c = Definition of $f$
}}
{{eqn | r = -\int_0^\pi \cos n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} x \cos n x \rd x - \int_\pi^{2 \pi} \cos n x \rd x
      | c = Linear Combination of Definite Integrals
}}
{{eqn | r = -\int_0^{2 \pi} \cos n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} x \cos n x \rd x
      | c = Sum of Integrals on Adjacent Intervals for Continuous Functions
}}
{{eqn | r = 0 + \frac 1 \pi \int_\pi^{2 \pi} x \cos n x \rd x
      | c = Integral over $2 \pi$ of $\cos n x$
}}
{{eqn | r = \frac 1 \pi \intlimits {\frac {\cos n x} {n^2} + \frac {x \sin n x} n} \pi {2 \pi}
      | c = Primitive of $x \cos n x$
}}
{{eqn | r = \frac 1 \pi \paren {\frac {\cos 2 n \pi} {n^2} + \frac {2 \pi \sin 2 n \pi} n} - \frac 1 \pi \paren {\frac {\cos n \pi} {n^2} + \frac {\pi \sin n \pi} n}
      | c = 
}}
{{eqn | r = \frac 1 \pi \paren {\frac {\cos 2 n \pi} {n^2} - \frac {\cos n \pi} {n^2} }
      | c = Sine of Multiple of Pi
}}
{{eqn | r = \frac {1 - \paren {-1}^n} {n^2 \pi}
      | c = Cosine of Multiple of Pi and simplifying
}}
{{eqn | r = \begin {cases} \dfrac 2 {n^2 \pi} & : \text {$n$ odd} \\ 0 & : \text {$n$ even} \end {cases}
      | c = separating out the odd and even cases
}}
{{eqn | r = \frac 2 {\pi \paren {2 r + 1}^2}
      | c = setting $n = 2 r + 1$ for odd $n$
}}
{{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 {-\pi} \sin n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} \paren {x - \pi} \sin n x \rd x
      | c = Definition of $f$
}}
{{eqn | r = -\int_0^\pi \sin n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} x \sin n x \rd x - \int_\pi^{2 \pi} \sin n x \rd x
      | c = Linear Combination of Definite Integrals
}}
{{eqn | r = -\int_0^{2 \pi} \sin n x \rd x + \frac 1 \pi \int_\pi^{2 \pi} x \sin n x \rd x
      | c = Sum of Integrals on Adjacent Intervals for Continuous Functions
}}
{{eqn | r = 0 + \frac 1 \pi \int_\pi^{2 \pi} x \sin n x \rd x
      | c = Integral over $2 \pi$ of $\sin n x$
}}
{{eqn | r = \frac 1 \pi \intlimits {\frac {\sin n x} {n^2} - \frac {x \cos n x} n} \pi {2 \pi}
      | c = Primitive of $x \sin n x$
}}
{{eqn | r = \frac 1 \pi \paren {\frac {\sin 2 n \pi} {n^2} - \frac {2 \pi \cos 2 n \pi} n} - \frac 1 \pi \paren {\frac {\sin \pi} {n^2} - \frac {\pi \cos \pi} n}
      | c = 
}}
{{eqn | r = \frac {-2 \cos 2 n \pi + \cos n \pi} n
      | c = Sine of Multiple of Pi and simplifying
}}
{{eqn | r = \frac {-2 + \paren {-1}^n} n
      | c = Cosine of Multiple of Pi
}}
{{eqn | r = -\frac {2 - \paren {-1}^n} n
      | c = rearranging
}}
{{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 = \frac 1 2 \paren {-\frac \pi 2} + \sum_{r \mathop = 0}^\infty \frac 2 {\pi \paren {2 r + 1}^2} \cos \paren {2 r + 1} x + \sum_{n \mathop = 1}^\infty \paren {-\frac {2 - \paren {-1}^n} n} \sin n x
      | c = substituting for $a_0$, $a_n$ and $b_n$ from above
}}
{{eqn | r = -\frac \pi 4 + \frac 2 \pi \sum_{r \mathop = 0}^\infty \frac {\cos \paren {2 r + 1} x} {\paren {2 r + 1}^2} - \sum_{n \mathop = 1}^\infty \frac {2 - \paren {-1}^n \sin n x} n
      | c = simplifying
}}
{{end-eqn}}
{{qed}}