Let $a,b,A,B \in {\mathbb N}$ subject to $(a-b)^2 + (A-B)^2 > 0$.
Now let $a_1,a_2,b_1 \in {\mathbb R}$ and define:
\begin{eqnarray}
P_0 &:=& a^2 (a_1-a_2-1) (a_1-a_2+1)+2 a b (2 a_1 a_2-a_1 b_1-a_2 b_1+b_1)+b^2 (b_1-2) b_1 \\
P_1 &:=& 2 (A (a (a_1-a_2-1) (a_1-a_2+1)+b (2 a_1 a_2-a_1 b_1-a_2 b_1+b_1))+B (a (2 a_1 a_2-a_1 b_1-a_2 b_1+b_1)+b
(b_1-2) b_1)) \\
P_2 &:=& A^2 (a_1-a_2-1) (a_1-a_2+1)+2 A B (2 a_1 a_2-a_1 b_1-a_2 b_1+b_1)+B^2 (b_1-2) b_1
\end{eqnarray}
Then the fundamental solutions to the following ODE:
\begin{eqnarray}
\frac{d^2 y(x)}{d x^2} - (a B-A b)^2\frac{\left(P_0 + P_1 x + P_2 x^2\right)}{4 (a+A x)^2 (b+B x)^2 (a-b+ (A-B)x)^2} \cdot y(x) = 0
\end{eqnarray}
have the following form:
\begin{eqnarray}
&&y_1(x) := (a+A x)^{b_1/2} (b+B x)^{\frac{1}{2} (-a_1-a_2+1)} (a+x (A-B)-b)^{\frac{1}{2} (a_1+a_2-b_1+1)} \, _2F_1\left(a_1,a_2;b_1;\frac{a+A x}{b+B x}\right)\\
&&\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!y_2(x) := (a+A x)^{1-\frac{b_1}{2}} (b+B x)^{\frac{1}{2} (-a_1-a_2-1)+b_1} (a+x (A-B)-b)^{\frac{1}{2} (a_1+a_2-b_1+1)} \,
_2F_1\left(a_1-b_1+1,a_2-b_1+1;2-b_1;\frac{a+A x}{b+B x}\right)
\end{eqnarray}
The following Mathematica code verifies the result:
In[1109]:= A =.; B =.; a =.; b =.; Clear[y1]; Clear[y2]; Clear[v]; x =.;
{A, B, a, b} = RandomInteger[{0, 20}, 4];
v[x_] := (-A b + a B)^2/(
4 (a + A x)^2 (a - b + A x - B x)^2 (b +
B x)^2) (a^2 (-1 + a1 - a2) (1 + a1 - a2) + b^2 (-2 + b1) b1 +
2 a b (2 a1 a2 + b1 - a1 b1 - a2 b1) +
2 (A (a (-1 + a1 - a2) (1 + a1 - a2) +
b (2 a1 a2 + b1 - a1 b1 - a2 b1)) +
B (b (-2 + b1) b1 +
a (2 a1 a2 + b1 - a1 b1 - a2 b1))) x + (A^2 (-1 + a1 -
a2) (1 + a1 - a2) + B^2 (-2 + b1) b1 +
2 A B (2 a1 a2 + b1 - a1 b1 - a2 b1)) x^2);
y1[x_] := (a + A x)^(b1/2) (a - b + (A - B) x)^(
1/2 (1 + a1 + a2 - b1)) (b + B x)^(1/2 (1 - a1 - a2))
Hypergeometric2F1[a1, a2, b1, (A x + a)^1/(B x + b)^1];
y2[x_] := (a + A x)^(1 - b1/2) (a - b + (A - B) x)^(
1/2 (1 + a1 + a2 - b1)) (b + B x)^(1/2 (-1 - a1 - a2) + b1)
Hypergeometric2F1[1 + a1 - b1, 1 + a2 - b1,
2 - b1, (A x + a)^1/(B x + b)^1];
FullSimplify[(D[#, {x, 2}] - v[x] #) & /@ {y1[x], y2[x]}]
Out[1114]= {0, 0}
Update 0: The result above can be used to solve the following inverse problem.
Let $A=B=1$. Now let $a,b \in {\mathbb N}$ and let $P_0,P_1,P_2 \in {\mathbb N}$ subject to $P_0^2 + P_1^2 + P_2^2 > 0$. Then there always exist certain $a_1,a_2,b_1 \in {\mathbb R}$ such that the functions $y_{1,2}(x)$ above are fundamental solutions to the following ODE:
\begin{eqnarray}
\frac{d^2 y(x)}{d x^2} - \frac{(P_0+P_1 x+P_2 x^2)}{(x+a)^2(x+b)^2} \cdot y(x)=0
\end{eqnarray}
Indeed if we set $A=B=1$ and then if we set $a,b \in {\mathbb N}$ in the top three equations defining $P_0,P_1,P_2$ above we can always solve those equations for $a_1,a_2,b_1$. Here is the Mathematica code that accomplishes that:
In[1473]:= {A, B} = {1, 1}; Clear[y1]; Clear[y2];
y1[x_] := (a + A x)^(b1/2) (a - b + (A - B) x)^(
1/2 (1 + a1 + a2 - b1)) (b + B x)^(1/2 (1 - a1 - a2))
Hypergeometric2F1[a1, a2, b1, (A x + a)^1/(B x + b)^1];
y2[x_] := (a + A x)^(1 - b1/2) (a - b + (A - B) x)^(
1/2 (1 + a1 + a2 - b1)) (b + B x)^(1/2 (-1 - a1 - a2) + b1)
Hypergeometric2F1[1 + a1 - b1, 1 + a2 - b1,
2 - b1, (A x + a)^1/(B x + b)^1];
{a, b} = RandomInteger[{0, 10}, 2];
{P0, P1, P2} = RandomInteger[{0, 10}, 3];
a1 =.; a2 =.; b1 =.;
subst = FullSimplify[
Solve[{a^2 (-1 + a1 - a2) (1 + a1 - a2) + b^2 (-2 + b1) b1 +
2 a b (2 a1 a2 + b1 - a1 b1 - a2 b1),
2 (A (a (-1 + a1 - a2) (1 + a1 - a2) +
b (2 a1 a2 + b1 - a1 b1 - a2 b1)) +
B (b (-2 + b1) b1 +
a (2 a1 a2 + b1 - a1 b1 - a2 b1))) , (A^2 (-1 + a1 -
a2) (1 + a1 - a2) + B^2 (-2 + b1) b1 +
2 A B (2 a1 a2 + b1 - a1 b1 - a2 b1))} == 4 {P0, P1, P2}, {a1,
a2, b1}]];
subst = Sort[{a1, a2, b1} /. subst, #1[[3]] < #2[[3]] &];
MatrixForm[subst]
aa = FullSimplify[(D[#, {x, 2}] - (
P0 + P1 x + P2 x^2)/((x + a)^2 (x + b)^2) #) & /@ {y1[x],
y2[x]}]
FullSimplify[aa /. Diagonal[Thread[{a1, a2, b1} -> #] & /@ subst[[1]]]]
Out[1483]= {0, 0}
In this particular example we had $\{a,b\}=\{9,7\}$,$\{P_0,P_1,P_2\}=\{ 0,4,9\}$ and
\begin{eqnarray}
\left(\begin{array}{r}a_1\\a_2\\b_1\end{array}\right)=\left(
\begin{array}{r}\frac{1}{2} \left(1+\sqrt{37}+3 \sqrt{46}-\sqrt{694}\right)\\\frac{1}{2} \left(1-\sqrt{1145+12 \sqrt{7981}-4 \sqrt{37 \left(277+3 \sqrt{7981}\right)}}\right)\\1-\sqrt{694}\end{array}\right)
\end{eqnarray}
Update 1: Now let us go back to Update 0 and let us take some particular examples where we can indeed give closed form solutions .
(A)
If we set $P_2=P_1=0$ and $P_0 \neq 0$ then we get the following:
\begin{eqnarray}
a_1 &=& 1\\
a_2 &=& 1+\frac{\sqrt{(a-b)^2+4 P_0}}{a-b}\\
b_1 &=& a_2
\end{eqnarray}
Therefore the solutions to
\begin{equation}
\frac{d^2 y(x)}{d x^2} - \frac{P_0}{(x+a)^2(x+b)^2} y(x)=0
\end{equation}
are
\begin{eqnarray}
y_1(x) &=& {(a+x)^{\frac{1}{2}+\frac{\sqrt{(a-b)^2+4 \text{P0}}}{2 (a-b)}} (b+x)^{\frac{1}{2}-\frac{\sqrt{(a-b)^2+4 \text{P0}}}{2 (a-b)}}}\\
y_2(x) &=& {(a+x)^{\frac{1}{2}-\frac{\sqrt{(a-b)^2+4 \text{P0}}}{2 (a-b)}}
(b+x)^{\frac{1}{2}+\frac{\sqrt{(a-b)^2+4 \text{P0}}}{2 (a-b)}}}
\end{eqnarray}
Note that :
\begin{eqnarray}
\lim_{b\rightarrow a} y_{1,2}(x) = (x+a) \exp\left( \pm \frac{\sqrt{P_0}}{x+a}\right)
\end{eqnarray}
as it should be.
(B) Likewise let use take $P_2=P_0=0$ and $P_1 \neq 0$. Then we are getting the following solution:
\begin{eqnarray}
a_2 &=& 1-\frac{\sqrt{\sqrt{16 a b P_1^2-4 P_1 (a+b) (a-b)^2+(a-b)^4}-2 P_1 (a+b)+(a-b)^2}}{\sqrt{2} (a-b)}\\
a_1 &=& 1-\frac{P_1}{(1-a_2) (b-a)}\\
b_1 &=& -1+a_1+a_2
\end{eqnarray}
Therefore the solutions to
\begin{equation}
\frac{d^2 y(x)}{d x^2} - \frac{P_1 x}{(x+a)^2(x+b)^2} y(x)=0
\end{equation}
are
\begin{eqnarray}
y_1(x) &=& (a+x)^{b_1/2} (b+x)^{\frac{1}{2} (-a_1-a_2+1)} \, _2F_1\left(a_1,a_2;b_1;\frac{a+x}{b+x}\right)\\
y_2(x) &=& (a+x)^{1-\frac{b_1}{2}} (b+x)^{\frac{1}{2} (-a_1-a_2-1)+b_1} \, _2F_1\left(a_1-b_1+1,a_2-b_1+1;2-b_1;\frac{a+x}{b+x}\right)
\end{eqnarray}
Note that:
\begin{eqnarray}
\lim_{b\rightarrow a_+} a_2 &=& 1+ \omega\\
a_1 &=& 1-\frac{4 a \omega}{\theta} \\
b_1 &=& \omega + 1 - \frac{4 a \omega}{\theta}
\end{eqnarray}
where $\omega := \frac{\imath}{2} \sqrt{\frac{P_1}{a}}$ and $\theta:=b-a$.
Therefore we have:
\begin{eqnarray}
&&\theta^{1+\omega}\cdot y_1(x) =\\
&& (x+a)^{\frac{\omega+1}{2}-\frac{2 a \omega}{\theta}} \cdot (x+a +\theta)^{\frac{1}{2}(-1-\omega+\frac{4 a}{\omega})} \cdot \theta^{1+\omega} F_{2,1}\left[
\begin{array}{rr}
1+\omega & 1- \frac{4 a \omega}{\theta}\\
& \omega+1-\frac{4 a \omega}{\theta}
\end{array};
\frac{x+a}{x+a+\theta}
\right]=\\
&&\left(1+\frac{\theta}{x+a}\right)^{\frac{2 a \omega}{\theta}} \cdot \theta^{1+\omega} F_{2,1}\left[
\begin{array}{rr}
1+\omega & 1- \frac{4 a \omega}{\theta}\\
& \omega+1-\frac{4 a \omega}{\theta}
\end{array};
\frac{x+a}{x+a+\theta}
\right] \underbrace{=}_{\theta \rightarrow 0}\\
&&e^{\frac{2 a \omega}{x+a}}\cdot (x+a) (-4 a \omega)^\omega U(\omega,0;-\frac{4a \omega}{x+a})
\end{eqnarray}
See Compute a limit that involves a hypergeometric function. for explanations.
In case of the second function $(a_1,a_2,b_1) \rightarrow (a_1-b_1+1,a_2-b_1+1,2-b_1)$ which is equivalent to $\omega \rightarrow -\omega$
and therefore :
\begin{eqnarray}
\lim_{b\rightarrow a} y_{1,2}(x) = (x+a) \cdot \exp\left(\pm \frac{2 a \omega}{x+a}\right) \cdot U(\pm\omega,0;\mp\frac{4 a \omega}{x+a})
\end{eqnarray}
where $U$ is the confluent hypergeometric function.
(C) Now let us assume that $P_0=P_1=0$ and $P_2\neq 0$. Define $Q:=\sqrt{1+4 P_2}$. Then we have:
\begin{eqnarray}
&&a_2^4 (a-b)^2+\\
&&-2 a_2^3 (Q+1) (a-b)^2+\\
&&a_2^2 \left(a^2 (4 P_2+3 Q+2)-2 a b (6 P_2+3 Q+2)+b^2 (4 P_2+3 Q+2)\right)+\\
&&-a_2 \left(a^2 (4 P_2+Q+1)-2 a b (2 P_2 (Q+3)+Q+1)+b^2 (4 P_2+Q+1)\right)+\\
&&-2 a b P_2 (Q+1)=0\\
&&\hline\\
a_1&=& \frac{b (a_2 Q+a_2-4 P_2-Q-1)-a (a_2-1) (Q+1)}{(a-b) (-2 a_2+Q+1)}\\
b_1&=&a_1+a_2-Q
\end{eqnarray}
Therefore the solutions to
\begin{equation}
\frac{d^2 y(x)}{d x^2} - \frac{P_2 x^2}{(x+a)^2(x+b)^2} y(x)=0
\end{equation}
are
\begin{eqnarray}
y_1(x) &=& (a+x)^{b_1/2} (b+x)^{\frac{1}{2} (-a_1-a_2+1)} \, _2F_1\left(a_1,a_2;b_1;\frac{a+x}{b+x}\right)\\
y_2(x) &=& (a+x)^{1-\frac{b_1}{2}} (b+x)^{\frac{1}{2} (-a_1-a_2-1)+b_1} \, _2F_1\left(a_1-b_1+1,a_2-b_1+1;2-b_1;\frac{a+x}{b+x}\right)
\end{eqnarray}
Now the calculation of the limit of $b$ going to $a$ is very similar to the case before so we only present the result. We have:
\begin{eqnarray}
\lim_{b\rightarrow a} y_{1,2}(x) = \left(x+a \right)^{\frac{1-Q}{2}}\cdot \exp\left(\mp \frac{a\sqrt{Q^2-1}}{2(x+a)} \right) \cdot U\left(\frac{1}{2}(1+Q\mp\sqrt{Q^2-1}),1+Q;\pm \frac{a\sqrt{Q^2-1}}{x+a} \right)
\end{eqnarray}
where $Q:=\sqrt{1+4 P_2}$.
(D) Now let us assume that $P_0$,$P_1$ and $P_2$ are arbitrary subject to $P_1 > 2 a P_2$. Then we have:
\begin{eqnarray}
&&a_2^4 (a-b)^2+\\
&&-2 a_2^3 (Q+1) (a-b)^2+\\
&&a_2^2 \left(a^2 (4 P_2+3 Q+2)+2 a (P_1-b (6 P_2+3 Q+2))+b^2 (4 P_2+3 Q+2)+2 b P_1-4 P_0\right)+\\
&&a_2 \left(a^2 (-(4 P_2+Q+1))+2 a (b (2 P_2 (Q+3)+Q+1)-P_1
(Q+1))-b^2 (4 P_2+Q+1)-2 b P_1 (Q+1)+4 P_0 (Q+1)\right)+\\
&&a (Q+1) (P_1-2 b P_2)+P_1 (b Q+b+P_1)-2 P_0 (2 P_2+Q+1)=0\\
&&\hline\\
&&a_1=\frac{-a (a_2-1) (Q+1)+b (a_2 Q+a_2-4 P_2-Q-1)+2 P_1}{(a-b) (-2 a_2+Q+1)}\\
&&b_1=a_1+a_2-Q
\end{eqnarray}
Therefore the solutions to
\begin{equation}
\frac{d^2 y(x)}{d x^2} - \frac{P_0+P_1 x+P_2 x^2}{(x+a)^2(x+b)^2} y(x)=0
\end{equation}
are
\begin{eqnarray}
y_1(x) &=& (a+x)^{b_1/2} (b+x)^{\frac{1}{2} (-a_1-a_2+1)} \, _2F_1\left(a_1,a_2;b_1;\frac{a+x}{b+x}\right)\\
y_2(x) &=& (a+x)^{1-\frac{b_1}{2}} (b+x)^{\frac{1}{2} (-a_1-a_2-1)+b_1} \, _2F_1\left(a_1-b_1+1,a_2-b_1+1;2-b_1;\frac{a+x}{b+x}\right)
\end{eqnarray}
In the limit $b$ going to $a$ we have the following result:
\begin{eqnarray}
\lim_{b\rightarrow a} y_{1,2}(x) = \left(x+a\right)^{\frac{1-Q}{2}}\cdot \exp\left(\pm \frac{R}{x+a}\right)\cdot U\left(\frac{1}{2}(1+Q\pm\frac{-P_1+2 a P_2}{R}),1+Q;\mp \frac{2 R}{x+a} \right)
\end{eqnarray}
where $Q:=\sqrt{1+4 P_2}$ and $R:=\sqrt{P_0-P_1 a+P_2 a^2}$.