<s>[INST] What is Riemann sum of this integral and using it to prove this This is Question 11.19 (e) part of Tom Apostol's Mathematical Analysis.

Let $f$ be a function of period $2\pi$  whose values on $[-\pi ,\pi]$ are $f(x)=1$ if $0<x < \pi$, $f(x)=0$ if $x =\pi$, or $0$ and $f(x)=-1$ if $-\pi <x<0$ and  $f(x)= 4/\pi \sum_{n=1}^{\infty} \frac{\sin(2n-1) x} {(2n-1)} dx$, for every $x$.
Consider the function$s_n(x)=\frac{2}{\pi} \int_{0}^{x} \frac{\sin (2nt)} {\sin (t)} dt $ . I proved that this function has local maxima at $x_1, x_3, x_5,\dots, x_{2n-1}$ where $x_m=\frac{m \pi } {2n}$.


The question is Interpret   $s_n ( \frac{\pi} {2n}) $  as a Riemann sum and prove that $\lim_{n\to \infty} s_n( \frac{\pi} {2n}) = \frac{2}{\pi} \int_{0}^{\pi} \frac{\sin t}{t} dt$ .

I am getting different answer/ answer which is not even close to this representation when I used Riemann sum method on $f(x)= 4/\pi \sum_{n=1}^{\infty} \frac{\sin(2n-1) x} {(2n-1)}\, dx$ so I request you to kindly outline a proof. No need to fully  solve it.
I have tried this a lot but couldn't solve it.
Thanks
 [/INST] The partial sum of the Fourier series for $f$ evaluated at $x = \frac{\pi}{4n}$ is
$$s_n\left(\frac{\pi}{2n}\right) = \frac{4}{\pi}\sum_{k=1}^n\frac{\sin\frac{(2k-1)\pi}{2n} }{2k-1}$$
Consider a partition $P_n: 0 < \frac{\pi}{2n}< \frac{3\pi}{2n} < \frac{5\pi}{2n} < \ldots < \frac{(2n-1)\pi}{2n}< \pi$ of the interval $[0,\pi]$ and the function
$$g(x) = \begin{cases}\frac{\sin x }{x}, & 0 < x \leqslant \pi \\1, & x = 0 \end{cases}$$
The partition points are given by  $x_0 = 0$, $x_k = \frac{(2k-1)\pi}{2n}$ for $k = 1, \ldots, n$, and $x_{n+1} = \pi$ and the Riemann sum for $g$ using right endpoints of the subintervals as tags is
$$S(P_n,g) = \sum_{k=1}^{n+1}f(x_k) (x_k - x_{k-1}) = \\\frac{\sin \frac{\pi}{2n}}{\frac{\pi}{2n}}\left( \frac{\pi}{2n}-0\right)+\sum_{k=1}^{n}\frac{\sin\frac{(2k-1)\pi}{2n} }{\frac{(2k-1)\pi}{2n}}\left(\frac{(2k-1)\pi}{2n}- \frac{(2k-3)\pi}{2n} \right) +\frac{\sin \pi}{\pi}\left( \pi - \frac{(2n-1)\pi}{2n}\right)\\ = \sin \frac{\pi}{2n}+ \sum_{k=1}^{n}\frac{\sin\frac{(2k-1)\pi}{2n} }{\frac{(2k-1)\pi}{2n}}\frac{\pi}{n} = \sin \frac{\pi}{2n}+ 2\sum_{k=1}^{n}\frac{\sin\frac{(2k-1)\pi}{2n} }{2k-1}$$
Hence,
$$s_n\left(\frac{\pi}{2n}\right)= \frac{2}{\pi}\cdot 2\sum_{k=1}^{n}\frac{\sin\frac{(2k-1)\pi}{2n} }{2k-1} = \frac{2}{\pi}S(P_n,g) - \frac{2}{\pi}\sin \frac{\pi}{2n}$$
Since the Riemann sum $S(P_n,g)$ converges to $\int_0^\pi g(x) \, dx = \int_0^\pi \frac{\sin x}{x} \,dx$ as $n \to \infty$, we have
$$\lim_{n \to \infty}s_n\left(\frac{\pi}{2n}\right) = \lim_{n \to \infty}\frac{2}{\pi}S(P_n,g) -  \lim_{n \to \infty}\frac{2}{\pi}\sin \frac{\pi}{2n} = \frac{2}{\pi} \int_0^\pi \frac{\sin x}{x} \, dx$$

The expression for $s_n(x)$ given in the problem is equal to the partial sum used above.
Differentiating  $s_n\left(x\right) = \frac{4}{\pi}\sum_{k=1}^n\frac{\sin(2k-1)x }{2k-1}$ we get
$$s_n'\left(x\right) = \frac{4}{\pi}\sum_{k=1}^n\cos(2k-1)x,$$
which can be summed in closed form and integrated to obtain
$$s_n(x) = \frac{2}{\pi} \int_{0}^{x} \frac{\sin 2nt} {\sin t} dt$$
In this form we have
$$s_n\left(\frac{\pi}{2n}\right) = \frac{2}{\pi} \int_{0}^{\frac{\pi}{2n}} \frac{\sin 2nt} {\sin t}\, dt = \frac{2}{\pi} \int_{0}^{\pi} \frac{\sin u} {2n \sin \frac{u}{2n}}\, du =  \frac{2}{\pi} \int_{0}^{\pi} \frac{\sin u}{u} \frac{\frac{u}{2n}}{ \sin \frac{u}{2n}}\, du,$$
and by the dominated convergence theorem
$$\lim_{n \to \infty}s_n\left(\frac{\pi}{2n}\right) = \frac{2}{\pi} \int_{0}^{\pi} \frac{\sin u}{u}\, du$$
</s>