Is my Fourier Series computation done correctly? See my fourier series calculation of this function if you please! 
$
     f(t)=\left\{\begin{array}{ll} 0, & \text{for } \ -\pi<t<0  \\
         1, & \text{for } \ 0 < t < \pi\end{array}\right. .
$
I start by calculation of the coefficient $a_0,a_k,b_k$: $$a_0=\frac{1}{\pi} \int\limits_{0}^{\pi}1\mathrm dt=1 ;$$ $$ a_k=\frac{1}{\pi}\int\limits_{0}^{\pi}\sin(kt)\mathrm dt=\frac{1-\cos(\pi k)}{\pi k} = \frac{1-(-1)^{k}}{\pi k};$$ $$ b_k= \frac{1}{\pi}\int\limits_{0}^{\pi}\cos(kt)\mathrm dt = \frac{\sin(\pi t)}{k} = 0$$
We will get: $f(t) \sim \frac{1}{2} + \sum\limits_{k=0}^{\infty}\frac{1-(-1)^{k}}{\pi k}\sin(kt) = \frac{1}{2} + \sum\limits_{n=0}^{\infty}\frac{2}{\pi (2n+1)}\sin((2n+1)t) $
How we can find relationship : $\sum\limits_{n=0}^{\infty}\frac{(-1)^n}{2n+1}=\frac{\pi}{4}$ from this fourier series ? 
 A: $$\begin{equation*} % a_0
f(t)=\begin{cases}0,&-\pi<t<0\\1,&0<t<\pi \end{cases}
\end{equation*}$$

\begin{equation*}a=-\pi\qquad l=\pi\qquad a+2l=\pi\qquad\qquad\qquad\end{equation*}

$$\begin{equation*}S(t)=\frac{a_0}2+\sum\limits_{k=1}^\infty a_k\cos\left(\frac{k\pi x}l\right)+b_k\sin\left(\frac{k\pi t}l\right)\\
\\
a_0=\frac1l\int\limits_{a}^{a+2l}f(t)\mathrm dt\qquad a_k=\frac1l\int\limits_{a}^{a+2l}f(t)\cos(t)\mathrm dt\qquad b_k=\frac1l\int\limits_{a}^{a+2l}f(t)\sin(t)\mathrm dt\\
\\\end{equation*}$$

\begin{align*} % a_0
a_0&=\frac1\pi\int\limits_{-\pi}^\pi f(t)\,\text dt\\
&=\frac1\pi\int\limits_{0}^\pi\,\text dt\\
&=\frac t\pi \Big|_0^\pi\\
&=\frac{\pi-0}\pi\\
&=1\\
\end{align*}
\begin{align*} %a_k
a_k&=\frac1\pi\int\limits_{-\pi}^\pi f(t)\cos(kt)\,\text dt\\
&=\frac1\pi\int\limits_{0}^\pi \cos(kt)\,\text dt\\
&=\frac1\pi\frac{\sin(kt)}k\Big|_0^\pi\\
&=\frac{\sin(k\pi)}{\pi k}\\
&=0
\end{align*}
\begin{align*} % b_k
b_k&=\frac1\pi\int\limits_{-\pi}^\pi f(t)\sin(kt)\,\text dt\\
&=\frac1\pi\int\limits_{0}^\pi\sin(kt)\,\text dt\\
&=\frac{-\cos(kt)}{\pi k}\Big|_0^\pi\\
&=\frac{\cos(0)-\cos(k\pi)}{k\pi }\\
&=\frac{1-(-1)^k}{k\pi }\\
&=\frac{1+(-1)^{k+1}}{k\pi }\\
\end{align*}

\begin{align*} % S(t)
S(t)&=\frac{1}2+\sum\limits_{k=1}^\infty \frac{1+(-1)^{k+1}}{k\pi }\sin\left({k t}\right)\\
&=\frac{1}2+\frac2\pi\sum\limits_{k=1,3,5,\dots}^\infty\frac{\sin({k t})}k\\
&=\frac{1}2+\frac2\pi\sum\limits_{r=1}^\infty\frac{\sin\big((2r-1)t\big)}{2r-1}\\
\\
&=\frac12+\frac2\pi\left(\sin(t)+\frac{\sin(3t)}3+\frac{\sin(5t)}5+\dots\right)
\end{align*}


\begin{align*} % S(t)
S(t)
&=\frac{1}2+\frac2\pi\sum\limits_{r=1}^\infty\frac{\sin\big((2r-1)t\big)}{2r-1}\\
\\
\\% S(π/2)
S\left(\tfrac\pi2\right)
&=\frac{1}2+\frac2\pi\sum\limits_{r=1}^\infty\frac{\sin(\pi r-\tfrac\pi2)}{2r-1}\\
1&=\frac{1}2+\frac2\pi\sum\limits_{r=1}^\infty\frac{(-1)^{r-1}}{2r-1}\\
\frac\pi4&=\sum\limits_{r=1}^\infty\frac{(-1)^{r-1}}{2r-1}\\
\\
\end{align*}
A: The Fourier series of $f$ is:
$$
\frac{1}{2}+\sum_{k=1}^{+\infty} \frac{1-(-1)^k}{k\pi}\sin(kt)=\frac{1}{2}+\sum_{n=0}^{+\infty}\frac{2}{(2n+1)\pi}\sin((2n+1)t).
$$
Now the function $f$ is differentiable at $t=\pi/2$.
By Dirichlet Theorem, we have convergence of the Fourier series to $f$ at this point:
$$
1=\frac{1}{2}+\sum_{n=0}^{+\infty}\frac{2}{(2n+1)\pi}\sin((2n+1)\pi/2)=\frac{1}{2}+\sum_{n=0}^{+\infty}\frac{2}{(2n+1)\pi}(-1)^n.
$$
This yields the required formula.
