Determine the Fourier series coefficient of the square wave.
I think my limits for $a_0$ and $a_n$ may be incorrect.
As the function is even, all the sine coefficients will be zero and we can integrate from $0$ to $\pi$ and double. Then
$$2\int_0^{\pi/2}\cos(kx)\,dx-2\int_{\pi/2}^\pi\cos(kx)\,dx=\frac{\sin(k\frac\pi2)-0-0+\sin(k\frac\pi2)}k$$
Copyright © 2021 JogjaFile Inc.
As the function is even, all the sine coefficients will be zero and we can integrate from $0$ to $\pi$ and double. Then
$$2\int_0^{\pi/2}\cos(kx)\,dx-2\int_{\pi/2}^\pi\cos(kx)\,dx=\frac{\sin(k\frac\pi2)-0-0+\sin(k\frac\pi2)}k$$