I have to solve the following integral $$I=\int_{\lambda_1}^yd\lambda\frac{1}{1-\lambda}\sqrt{\frac{(\lambda-\lambda_1)(\lambda-\lambda_2)(\lambda-\lambda_4)}{\lambda-\lambda_3}}$$ where $y>1>\lambda_1>\lambda_2>\lambda_3>\lambda_4>0$.
The problem, as you can see, is that the integral $I$ has non-integrable contribution at $\lambda=1$. So what I do basically to avoid the problem is to rewrite $I$ as
$$I=\lim_{r\to1}\int_{\lambda_1}^rd\lambda\frac{1}{1-\lambda}\sqrt{\frac{(\lambda-\lambda_1)(\lambda-\lambda_2)(\lambda-\lambda_4)}{\lambda-\lambda_3}}-\lim_{r\to1}\int_{r}^yd\lambda\frac{1}{\lambda-1}\sqrt{\frac{(\lambda-\lambda_1)(\lambda-\lambda_2)(\lambda-\lambda_4)}{\lambda-\lambda_3}}$$
I already could solve $$I_1=\lim_{r\to1}\int_{\lambda_1}^rd\lambda\frac{1}{1-\lambda}\sqrt{\frac{(\lambda-\lambda_1)(\lambda-\lambda_2)(\lambda-\lambda_4)}{\lambda-\lambda_3}}$$ using "P. F. Byrd and D. F. Morris, Handbook of elliptic integrals for engineers and scientists, Vol 67, Berlin Springer (1971)".
I only need to solve $$I_2=\int_{r}^yd\lambda\frac{1}{\lambda-1}\sqrt{\frac{(\lambda-\lambda_1)(\lambda-\lambda_2)(\lambda-\lambda_4)}{\lambda-\lambda_3}}$$ for $y>r>1$. The problem is that in this case I can not use "P. F. Byrd and D. F. Morris, Handbook of elliptic integrals for engineers and scientists, Vol 67, Berlin Springer (1971)" because in order to do it I will have to rewrite $I_2$ like a sum of two integrals with one of the limits of integration being $\lambda_i$ for $i\in\{1,\dots,4\}$ and if I do that I return to the case when there is no integrable contribution at $1$.
Could you please help me to solve $I_2$?
Looonnng-winded hint: The work below is admittedly a lot of algebra away from actually reaching an explicit final value for the desired integral, but I do think it covers the trickiest part of the derivation with the remainder being straightforward, though tedious.
As you pointed out in your question, since the singularity at $p$ is in the interval $(a,\infty)$, we can't write $\mathcal{E}$ as the difference of integrals $\int_{y}^{z}=\int_{a}^{z}-\int_{a}^{y}$ when the limits $y$ and $z$ are greater than $p$. Another option is to write $\mathcal{E}$ as a difference of integrals with limits at $+\infty$ instead of $a$. This avoids the problem of needing to integrate over a singularity, but there's a new issue in that these integrals diverge. But we can fix that....
First note the following partial fraction decomposition:
$$\begin{align} \small{\frac{\left(x-a\right)\left(x-b\right)\left(x-d\right)}{x-p}} &=\small{\frac{x^{3}-\left(a+b+d\right)x^{2}+\left(ab+ad+bd\right)x-abd}{x-p}}\\ &=\small{x^{2}+\frac{\left(p-a-b-d\right)x^{2}+\left(ab+ad+bd\right)x-abd}{x-p}}\\ &=\small{x^{2}+\left(p-a-b-d\right)x}\\ &~~~~~\small{+\frac{\left(p^{2}-pa-pb-pd+ab+ad+bd\right)x-abd}{x-p}}\\ &=\small{x^{2}+\left(p-a-b-d\right)x+\left(p^{2}-pa-pb-pd+ab+ad+bd\right)}\\ &~~~~~\small{+\frac{\left(p^{2}-pa-pb-pd+ab+ad+bd\right)p-abd}{x-p}}\\ &=\small{x^{2}+\left(p-a-b-d\right)x+\left(p^{2}-pa-pb-pd+ab+ad+bd\right)}\\ &~~~~~\small{+\frac{\left(p-a\right)\left(p-b\right)\left(p-d\right)}{x-p}}.\\ \end{align}$$
The first step to putting the elliptic integral in something closer to standard form is rewriting the integrand through rationalization so that there's a single square-root factor in the denominator with a quartic under the radical.
Letting $Q{\left(x\right)}$ stand for the quartic,
$$Q{\left(x\right)}:=\left(x-a\right)\left(x-b\right)\left(x-c\right)\left(x-d\right),$$
we decompose the elliptic integral $\mathcal{E}$ into a sum of four simpler integrals using the partial fraction expansion given above:
$$\begin{align} \mathcal{E} &=\int_{y}^{z}\frac{1}{x-p}\sqrt{\frac{\left(x-a\right)\left(x-b\right)\left(x-d\right)}{x-c}}\,\mathrm{d}x\\ &=\int_{y}^{z}\frac{\left(x-a\right)\left(x-b\right)\left(x-d\right)}{\left(x-p\right)\sqrt{\left(x-a\right)\left(x-b\right)\left(x-c\right)\left(x-d\right)}}\,\mathrm{d}x\\ &=\left(p^{2}-pa-pb-pd+ab+ad+bd\right)\int_{y}^{z}\frac{\mathrm{d}x}{\sqrt{Q{\left(x\right)}}}\\ &~~~~~+\left(p-a-b-d\right)\int_{y}^{z}\frac{x}{\sqrt{Q{\left(x\right)}}}\,\mathrm{d}x+\int_{y}^{z}\frac{x^{2}}{\sqrt{Q{\left(x\right)}}}\,\mathrm{d}x\\ &~~~~~+\left(p-a\right)\left(p-b\right)\left(p-d\right)\int_{y}^{z}\frac{\mathrm{d}x}{\left(x-p\right)\sqrt{Q{\left(x\right)}}}\\ &=:\left(p^{2}-pa-pb-pd+ab+ad+bd\right)I^{(0)}\\ &~~~~~+\left(p-a-b-d\right)I^{(1)}+I^{(2)}\\ &~~~~~+\left(p-a\right)\left(p-b\right)\left(p-d\right)J^{(1)}.\\ \end{align}$$
It remains to reduce each of the integrals $I^{(k)}$ and $J^{(1)}$ to standard form. The $I^{(k)}$ integrals are more or less straightforward since there are no singularity concerns in the integrands, so we focus first on the evaluation of $J^{(1)}$.
The convenient thing about the integral $J^{(1)}$ is that it does converge when the integration limits go to $+\infty$, unlike the case with $\mathcal{E}$.
Main Result:
Define $J{\left(Q;p;z\right)}$ by the improper integral,
$$J{\left(Q;p;z\right)}:=\int_{z}^{\infty}\frac{\mathrm{d}x}{\left(x-p\right)\sqrt{Q{\left(x\right)}}}.$$
Set $\kappa:=\sqrt{\frac{\left(a-d\right)\left(b-c\right)}{\left(a-c\right)\left(b-d\right)}}\land n:=\frac{\left(p-b\right)\left(a-d\right)}{\left(p-a\right)\left(b-d\right)}\land\varphi:=\arcsin{\left(\sqrt{\frac{\left(b-d\right)\left(z-a\right)}{\left(a-d\right)\left(z-b\right)}}\right)}\land\theta:=\arcsin{\left(\sqrt{\frac{b-d}{a-d}}\right)}$. Also, let $P{\left(y\right)}$ stand for the quartic expression $P{\left(y\right)}:=\left(1-y^{2}\right)\left(1-\kappa^{2}y^{2}\right)$. Using the substitution
$$\small{\sqrt{\frac{\left(b-d\right)\left(x-a\right)}{\left(a-d\right)\left(x-b\right)}}=y\implies x=\frac{a\left(b-d\right)-b\left(a-d\right)y^{2}}{b-d-\left(a-d\right)y^{2}}},$$
the integral $J{\left(Q;p;z\right)}$ will transform as:
$$\begin{align} J{\left(Q;p;z\right)} &=\int_{z}^{\infty}\frac{\mathrm{d}x}{\left(x-p\right)\sqrt{Q{\left(x\right)}}}\\ &=\small{\int_{\sqrt{\frac{\left(b-d\right)\left(z-a\right)}{\left(a-d\right)\left(z-b\right)}}}^{\sqrt{\frac{\left(b-d\right)}{\left(a-d\right)}}}\frac{\left(-1\right)2\left[b-d-\left(a-d\right)y^{2}\right]\,\mathrm{d}y}{\left[\left(p-a\right)\left(b-d\right)-\left(p-b\right)\left(a-d\right)y^{2}\right]\sqrt{\left(a-c\right)\left(b-d\right)}\sqrt{P{\left(y\right)}}}}\\ &=-\frac{2}{\left(p-b\right)\sqrt{\left(a-c\right)\left(b-d\right)}}\int_{\sqrt{\frac{\left(b-d\right)\left(z-a\right)}{\left(a-d\right)\left(z-b\right)}}}^{\sqrt{\frac{b-d}{a-d}}}\frac{\mathrm{d}y}{\sqrt{P{\left(y\right)}}}\\ &~~~~~\small{-\frac{2\left(a-b\right)}{\left(p-a\right)\left(p-b\right)\sqrt{\left(a-c\right)\left(b-d\right)}}\int_{\sqrt{\frac{\left(b-d\right)\left(z-a\right)}{\left(a-d\right)\left(z-b\right)}}}^{\sqrt{\frac{b-d}{a-d}}}\frac{\mathrm{d}y}{\left(1-ny^{2}\right)\sqrt{P{\left(y\right)}}}}\\ &=-\frac{2}{\left(p-b\right)\sqrt{\left(a-c\right)\left(b-d\right)}}\int_{\sin{\left(\varphi\right)}}^{\sin{\left(\theta\right)}}\frac{\mathrm{d}y}{\sqrt{\left(1-y^{2}\right)\left(1-\kappa^{2}y^{2}\right)}}\\ &~~~~~\small{-\frac{2\left(a-b\right)}{\left(p-a\right)\left(p-b\right)\sqrt{\left(a-c\right)\left(b-d\right)}}\int_{\sin{\left(\varphi\right)}}^{\sin{\left(\theta\right)}}\frac{\mathrm{d}y}{\left(1-ny^{2}\right)\sqrt{P{\left(y\right)}}}}\\ &=-\frac{2\left[F{\left(\theta,\kappa\right)}-F{\left(\varphi,\kappa\right)}\right]}{\left(p-b\right)\sqrt{\left(a-c\right)\left(b-d\right)}}\\ &~~~~~-\frac{2\left(a-b\right)\left[\Pi{\left(\theta,n,\kappa\right)}-\Pi{\left(\varphi,n,\kappa\right)}\right]}{\left(p-a\right)\left(p-b\right)\sqrt{\left(a-c\right)\left(b-d\right)}}.\\ \end{align}$$
Note that the parameter $n$ of the elliptic integrals of the third kind in the last line above is greater than $1$, and as such these integrals will be defined by Cauchy principle values.
The necessity for worrying about Cauchy principle values can be circumvented however, by using the following connection formula due to Legendre.
The above relationship maps elliptic integrals of third kind with parameters in the range $(1,\infty)$ to ones with parameter in the range $(0,k^2)$, which don't suffer any singularity issues in their definition.