Is there a closed form for the trigonometric integral $\int\limits_0^{\pi/4}\frac{\cos(2k+1)x}{\cos x} dx$?

One can easily show that $$\int\limits_0^{\pi}\frac{\cos(2k+1)x}{\cos x} dx = 2 \int\limits_0^{\frac{\pi}{2}}\frac{\cos(2k+1)x}{\cos x} dx = (-1)^k \pi$$.

But is there a closed form for $$\int\limits_0^{\frac{\pi}{4}}\frac{\cos(2k+1)x}{\cos x} dx$$ ?

So far, I tried by induction and by IBP but couldn't come to a simple closed form.

• Here is the example for $k=14$. It seems that the answer is $$(-1)^k \left( \frac{\pi}{4} - \sum_{n \le k, n\mbox{ odd}} \frac{(-1)^n}{n} \right)$$ Jan 15, 2019 at 19:10
Write $$\frac{\cos((2k+1) x)}{\cos(x)} = \mathrm{e}^{2 k \mathrm{i} x} \frac{1+\mathrm{e}^{-(2k+1) 2 \mathrm{i} x}}{1+\mathrm{e}^{-2\mathrm{i}x}} = \sum \limits_{l=0}^{2k} (-1)^l \mathrm{e}^{2 (k-l) \mathrm{i} x} = (-1)^k \left[1+2\sum \limits_{m=1}^k (-1)^m \cos(2mx)\right]$$ to obtain \begin{align} I_k &\equiv \int \limits_0^{\pi/4} \frac{\cos((2k+1) x)}{\cos(x)} \, \mathrm{d} x = (-1)^k \left[\frac{\pi}{4} + \sum \limits_{m=1}^k \frac{(-1)^m}{m} \sin\left(\frac{m\pi}{2}\right)\right] \\ &= (-1)^k \left[\frac{\pi}{4} - \sum \limits_{n=0}^{\lfloor \frac{k-1}{2}\rfloor} \frac{(-1)^n}{2n+1}\right] \end{align} for $$k \in \mathbb{N}_0$$ in agreement with Crostul's comment. In particular, $$\lim_{k \to \infty} I_k = 0$$ .
It is worthwhile to recall that for $$n\in\Bbb N$$, $$\cos nx=T_n(\cos x)$$ Where $$T_n(x)$$ is the Chebyshev polynomial of the first kind, defined as $$T_n(x)=\frac{n}2\sum_{r=0}^{\lfloor n/2\rfloor}\frac{(-1)^r}{n-r}{n-r\choose r}(2x)^{n-2r}$$ Hence $$I_k=\int_0^{\pi/4}\frac{\cos[(2k+1)x]}{\cos x}dx$$ $$I_k=\int_0^{\pi/4}\frac{2k+1}{2\cos x}\sum_{r=0}^{\lfloor \frac{2k+1}2\rfloor}\frac{(-1)^r}{2k+1-r}{2k+1-r\choose r}(2\cos x)^{2k-2r+1}dx$$ $$I_k=\frac{2k+1}{2}\sum_{r=0}^{\lfloor \frac{2k+1}2\rfloor}\frac{(-1)^r}{2k+1-r}{2k+1-r\choose r}2^{2k-2r+1}\int_0^{\pi/4}\cos(x)^{2k-2r}dx$$ $$I_k=(2k+1)\sum_{r=0}^{k}\frac{(-1)^r4^{k-r}}{2k-r+1}{2k-r+1\choose r}\int_0^{\pi/4}\cos(x)^{2k-2r}dx$$ Then we focus on the integral $$J(r,k)=\int_0^{\pi/4}\cos(x)^{2(k-r)}dx$$ Unfortunately, the closest to a closed form for this guy is something in terms of the incomplete Beta function. Here's how:
Consider the integral $$H(k;a,b)=\int_0^k\sin(x)^{a}\cos(x)^{b}dt$$ For some $$0\leq k\leq 1$$. Making the substitution $$t=\sin(x)^2$$, we see that $$H(k;a,b)=\frac12\int_0^{\sin(k)^2}t^{\frac{a-1}2}(1-t)^{\frac{b-1}2}dt$$ $$H(k;a,b)=\frac12\int_0^{\sin(k)^2}t^{\frac{a+1}2-1}(1-t)^{\frac{b+1}2-1}dt$$ Then Recall the definition of the incomplete Beta function: $$\mathrm{B}(x;a,b)=\int_0^x t^{a-1}(1-t)^{b-1}dt$$ Thus $$H(k;a,b)=\frac12\mathrm{B}\bigg(\sin(k)^2;\frac{a+1}2,\frac{b+1}2\bigg)$$ And $$J(r,k)=H(\pi/4;0,2k-2r)=\frac12\mathrm{B}\bigg(\frac12;\frac{1}2,k-r+\frac{1}2\bigg)$$ Thus $$I_k=\frac{2k+1}2\sum_{r=0}^{k}\frac{(-1)^r4^{k-r}}{2k-r+1}{2k-r+1\choose r}\mathrm{B}\bigg(\frac12;\frac{1}2,k-r+\frac{1}2\bigg)$$ Which could be considered a closed form.