Consider the even $\pi$-periodic function $f(x,k)=\sqrt{1-k^2 \sin^2 x}$ with Fourier cosine series $$f(x,k)=\frac{1}{2}a_0+\sum_{n=1}^\infty a_n \cos2nx,\quad a_n=\frac{2}{\pi}\int_0^{\pi} \sqrt{1-k^2 \sin^2 x}\cos 2nx \,dx.$$ This was considered in this earlier question, and in comments an observation was made: The Fourier coefficients all appear to be of the form $a_n= A_n(k) K(k)+B_n(k) E(k)$ where $K,E$ are the complete elliptic integrals of the first and second kind and $A_n(k),B_n(k)$ are rational functions of $k$.
This is made plausible by the fact that $f(x,k)$ is the first $x$-derivative of the incomplete elliptic integral of the second kind $E(x,k)=\int_0^x f(x',k)\,dx'$. Moreover, this conjecture for $a_k$ can be confirmed by examining the Fourier series of $E(x,k)$; this appears in a 2010 paper by D. Cvijovic, with full text available on ResearchGate.
Something we may conclude from this observation is that, since the Fourier coefficients are linear combinations of complete elliptic integrals, $f(x,k)$ itself must be of the form $A(x,k)K(k)+B(x,k)E(k)$ where $A(x,k), B(x,k)$ are even $\pi$-periodic functions whose Fourier coefficients are rational functions of $k$. Such a Fourier expansion of does appear in the paper noted above, but the functions themselves are not found in closed-form. Hence my question:
Can $A(x,k)$, $B(x,k)$ be obtained in closed-form in terms of known special functions?
We have: $$ \frac{\pi}{2}\,a_n=\int_{0}^{\pi}\sqrt{1-k^2\sin^2\theta}\cos(2n\theta)\,d\theta =\frac{k^2}{4n}\int_{0}^{\pi}\frac{\sin(2\theta)\sin(2n\theta)}{\sqrt{1-k^2\sin^2\theta}}\,d\theta.\tag{1}$$ If we set: $$ b_m = \int_{0}^{\pi}\frac{\cos(2m\theta)}{\sqrt{1-k^2\sin^2\theta}}\,d\theta,\qquad c_m = \int_{0}^{\pi}\cos(2m\theta)\sqrt{1-k^2\sin^2\theta}\,d\theta $$ we have: $$ b_m = \int_{0}^{\pi}\frac{\cos(2\theta)\cos((2m-2)\theta)}{\sqrt{1-k^2\sin^2\theta}}\,d\theta-\int_{0}^{\pi}\frac{\sin(2\theta)\sin((2m-2)\theta)}{\sqrt{1-k^2\sin^2\theta}}\,d\theta$$ and expressing $\cos(2\theta)$ as $1-2\sin^2\theta$ we get:
$$ b_m = \frac{2}{k^2}\int_{0}^{\pi}\frac{(k^2/2-k^2\sin^2\theta)\cos((2m-2)\theta)}{\sqrt{1-k^2\sin^2\theta}}\,d\theta-\frac{4(m-1)}{k^2}c_{m-1}$$ so: $$ b_m = \frac{2}{k^2} c_{m-1} + \frac{k^2-2}{k^2}b_{m-1}-\frac{4m-4}{k^2}c_{m-1} = \frac{k^2-2}{k^2}b_{m-1}-\frac{4m-2}{k^2}c_{m-1}. $$
Moreover, integration by parts gives: $$ c_m = \frac{k^2}{8m}\left(b_{m+1}-b_{m-1}\right), \tag{2}$$ hence: $$ b_m = \frac{k^2-2}{k^2}b_{m-1}-\frac{2m-1}{4m-4}(b_m-b_{m-2}), $$ $$ \frac{6m-5}{4m-4} b_m = \frac{k^2-2}{k^2}b_{m-1}+\frac{2m-1}{4m-4}b_{m-2}, $$ or:
Since $b_0 = 2 K(k) $ and $c_0 = 2 E(k)$ we have $$ b_1 = \frac{1}{k^2}\left((2k^2-4)K(k)+4E(k)\right).$$ In order to have explicit forms for $A(\theta,k)$ and $B(\theta,k)$, it is sufficient to find a closed-form expression for the recursion given by $(3)$, since, by $(1)$ and $(2)$: $$\frac{\pi}{2}a_n = c_n = \frac{k^2}{8n}\left(b_{m+1}-b_{m-1}\right).$$
By setting: $$ B(x)=\sum_{n\geq 0} b_n x^n $$ recursion $(2)$ can be converted into a first-order ODE for $B(x)$, giving that $B(x)$ behaves like the reciprocal of the square root of a cubic polynomial, and the radius of convergence of $B(x)$ is $\geq 2.485$. $A(\theta,k)$ and $B(\theta,k)$ can be recovered from $\Re\left(B(e^{2i\theta})\right)$.