<s>[INST] A Sine-Cosine Integral $\int_{0}^{\frac{\pi}{2}} \frac{ \sin(kx) \ +\ \cos(kx)}{\sin x \ +\ \cos x} \ dx$ What is the value of the integral
\begin{align}
I(k) = \int_{0}^{\frac{\pi}{2}} \frac{ \sin(kx) + \cos(kx)}{\sin(x) + \cos(x)} \ dx
\end{align}
where $k$ is an integer ?
Is it possible to evaluate a related integral
\begin{align}
I(k) = \int_{0}^{\frac{\pi}{2}} \frac{ \sin(kx) - \cos(kx)}{\sin(x) - \cos(x)} \ dx
\end{align}
where $k$ is an integer ?
 [/INST] Depending on even or odd $k$, the integrals
\begin{align}
I_k = \int_{0}^{\frac{\pi}{2}} \frac{ \sin(kx) + \cos(kx)}{\sin x + \cos x} \ dx
\end{align}
exhibit different behaviors. Their close-forms are derived separately below
\begin{align}
I_{2m+1} 
=& \>2\cos\frac{m\pi}2\int_0^{\frac\pi4}\frac{\cos(2m+1)x}{\cos x}dx
=\cos\frac{m\pi}2\left(\frac\pi2-\sum_{k=1}^m \frac{2}k \sin\frac{k \pi}2 \right)
\\
\\
 I_{2m} 
=& \>2\sin\frac{(2m+1)\pi}4\int_0^{\frac\pi4}\frac{\cos(2mx)}{\cos x}dx\\
=&\>2\cos\frac{(2m+1)\pi}4\left(\coth^{-1}\sqrt2-\sum_{k=1}^m \frac{2}{2k-1} \sin\frac{(2k+1)\pi}4\right)
\end{align}
from which
\begin{align}
&I_1=\frac\pi2,\>\>\>I_5=2-\frac\pi2,\>\>\>I_9=\frac\pi2-\frac43,
\>\>\>I_{13}=\frac{26}{15}-\frac\pi2,\cdots\\
&I_3=I_7=I_{11}=I_{15}=\cdots = 0\\
&I_2=2-\sqrt2 \coth^{-1}\sqrt2,\>\>\>
 I_4=\frac43-\sqrt2 \coth^{-1}\sqrt2,\>\>\>\\
 &I_6=\sqrt2 \coth^{-1}\sqrt2-\frac{14}{15},\>\>\>
 I_8=\sqrt2 \coth^{-1}\sqrt2- \frac{128}{105},\cdots\>\>\>
\end{align}
</s>