<s>[INST] Is this Fourier Series correct I need to confirm the Leibniz series through using Fourier series. I have done what I believe is the correct Fourier series just want to know if I am on the right path? If it is correct I don't see any way to evaluate it that comes out as Leibniz.
Leibniz: \begin{equation}
\frac{\pi}{4}=\sum_{i=0}^\infty \frac{(-1)^i}{(2i+1)}
\end{equation}
Function:
$$f(x) = \begin{cases}
0, &\text{for}\ -\pi<x<0 \\
1, &\text{for}\ 0\leq x<\pi
\end{cases}
$$
Fourier:
\begin{equation}
b_n = \frac{1}{\pi}\int_{-\pi}^\pi f(x) \sin(xn) dx=\frac{1}{\pi}(\int_{0}^\pi 1 \sin(xn) dx+\int_{-\pi}^0 0 \sin(xn) dx)=\frac{1}{\pi}(1/n)(-1(-1)^n+1)+0)=\frac{1-(-1)^n}{\pi*n}
\end{equation}
\begin{equation}
a_n =\frac{1}{\pi}(\int_{0}^\pi 1 \cos(xn) dx +\int_{-\pi}^0 0 \cos(xn) dx) = \frac{1}{\pi}(0+0)=0
\end{equation}
\begin{equation}
a_0 = \frac{1}{\pi}(\int_{0}^\pi 1  dx +\int_{-\pi}^0 0  dx)  = \frac{1}{\pi}(\pi-0+0)=1
\end{equation}
\begin{equation}
f(x) = \frac{a_0}{2}+\sum_{i=1}^\infty (a_n\cos(nx)+b_n\sin(nx)
=\frac{1}{2}+\sum_{i=1}^\infty (\frac{1-(-1)^n}{\pi*n}\sin(nx)
\end{equation}
 [/INST] What you have obtained is that
$$
f(x) = \frac{1}{2} + \sum_{n=1}^{\infty}\frac{1 - (-1)^n}{\pi n} \sin(nx).
$$
Therefore, it follows that, for $x = \frac{\pi}{2}$,
$$
\begin{align}
f(\pi/2) = 1 &= \frac{1}{2} + \sum_{n=1}^{\infty}\frac{1 - (-1)^n}{\pi n} \sin(n\pi/2) \\
\text{using the note from below} \\
&= \frac{1}{2} + \sum_{k=1}^{\infty}\frac{1 - (-1)^{4k-3}}{\pi (4k-3)}\sin\left(\frac{\pi(4k-3)}{2}\right) + \sum_{k=1}^{\infty}\frac{1 - (-1)^{4k-2}}{\pi (4k-2)}\sin\left(\frac{\pi(4k-2)}{2}\right) + \sum_{k=1}^{\infty}\frac{1 - (-1)^{4k-1}}{\pi (4k-1)}\sin\left(\frac{\pi(4k-1)}{2}\right) + \sum_{k=1}^{\infty}\frac{1 - (-1)^{4k}}{\pi (4k)}\sin\left(\frac{\pi(4k)}{2}\right)\\
&= \frac{1}{2} + \sum_{k=1}^{\infty}\frac{1 - (-1)^{4k-3}}{\pi (4k-3)} - \sum_{k=1}^{\infty}\frac{1 - (-1)^{4k-1}}{\pi (4k-1)} \\
&= \frac{1}{2} + \frac{2}{\pi}\left(\sum_{k=1}^{\infty}\frac{1}{(4k-3)} - \sum_{k=1}^{\infty}\frac{1}{(4k-1)}\right) \\
&= \frac{1}{2} + \frac{2}{\pi}\left(\sum_{k=1}^{\infty}\frac{(-1)^{k-1}}{2k-1}\right) \\
\text{shifting indices by 1, i.e. by letting $i = k-1$} \\
&= \frac{1}{2} + \frac{2}{\pi}\sum_{i=0}^{\infty}\frac{(-1)^{i}}{2i+1}.
\end{align}
$$
Equating the left and right hand sides then yields
$$
\frac{\pi}{4} = \sum_{i=0}^{\infty}\frac{(-1)^{i}}{2i+1},
$$
precisely as required.
Note:
In the above we used the fact that
$$
\sin\left(\frac{\pi n}{2}\right) = 
\begin{cases}
1 & \text{if } n = 4k-3,\ k \in \mathbb{N} \\
0 & \text{if } n = 4k-2,\ k \in \mathbb{N} \\
-1 & \text{if } n = 4k-1,\ k \in \mathbb{N} \\
0 & \text{if } n = 4k,\ k \in \mathbb{N},
\end{cases}
$$
for example
$$
\sin\left(\frac{n\pi}{2}\right) = 1, 0, -1, 0, 1, 0, -1,...
$$
for
$$
n = 1,2,3,4,5,6,7...
$$
respectively.
</s>