Suppose an expression $$ \tag 1 G(z) = \frac{1}{\sqrt{(z-1)^{3}(z+3)}}\text{K}\left( \sqrt{\frac{16z}{(z+3)(z-1)^{3}}}\right), $$ where $$ K(x) \equiv \int \limits_{0}^{\frac{\pi}{2}}\frac{dy}{\sqrt{1 - x^2\sin^{2}(y)}} $$ is complete elliptic integral of the first kind.
My task: I need to compute the imaginary part of $(1)$ for $0<z<3$.
What's the main challenge of the task? The region $0<z<3$ is divided on two sub-regions $0<z<1$ and $1<z<3$ because of a singularity in the factor $\frac{1}{\sqrt{(z-1)^{3}}}$, and it seems that I need to compute imaginary parts for these regions separately. Let's discuss behavior of the imaginary part of $(1)$ for these two regions.
In the region $0 < z < 1$ the prefactor in the front of $K(...)$ is purely imaginary, while $K(...)$ is real. In the region $1 < z < 3$ the prefactor is real, but the elliptic integral contains imaginary part, since its argument is real and larger than one. Therefore, naively the functional form of imaginary parts in two regions $0<z<1$ and $1<z<3$ must be different (at least I think so): they come from different functions.
It's possible to compute the imaginary parts in two regions analytically by using functional identities involving elliptic integrals. Surprisingly it turns out (after using one of identities) that functional dependences of imaginary parts in different regions are the same: $$ \text{Im }G(z) = -\frac{1}{2}\frac{1}{2\sqrt{z} + \frac{1}{2}\sqrt{(3-z)(z+1)^3}}\text{K}\left( \frac{2\left(z(3-z)(z+1)^{3}\right)^{\frac{1}{4}}}{2\sqrt{z}+\frac{1}{2}\sqrt{(3-z)(z+1)^{3}}}\right), \quad 0 < z < 3 $$ I can show this step-by-step, by evaluating the imaginary parts in the region $0<z<1$ and in the region $1<z<3$ and applying definite elliptic integrals functional identity to obtained relations.
But is it possible to calculate the imaginary part directly from $(1)$, without intermediate step of dividing the region $0<z<3$ onto $0<z<1$ and $1<z<3$?
An edit
One can think about the problem in another way. Precisely, after few manipulations the expression $(1)$ can be converted to the form $$ G(z) = \frac{i}{\sqrt{(3-z)(z+1)^{3}}}\text{K}\left( \sqrt{\frac{16z}{(3-z)(z+1)^{3}}}\right) $$ Now the prefactor is always purely imaginary, and $$ \text{Im }G(z) = \frac{1}{\sqrt{(3-z)(z+1)^{3}}}\text{Re }\text{K}\left( \sqrt{\frac{16z}{(3-z)(z+1)^{3}}}\right) $$ How to derive $\text{Re}[\text{K}(...)]$ without dividing the region onto two regions? It's obvious that the imaginary part is continuous function of $(...)$ except the singularity $z = 1$, where $(...) = 1$.