This is a follow-up to Yet another example of linear second order ODEs being reduced to hypergeometric functions. .
Let $A$,$A_1$,$B_1$,$B_2$,$C_1$ and $C_2$ be real numbers. Now define: \begin{eqnarray} C &=& \frac{A}{A_1} C_1 - \frac{A^2}{A_1^2} C_2\\ B &=& \frac{A}{A_1} B_1 - \frac{A^2}{A_1^2} B_2 \end{eqnarray}
Now consider a following ordinary differential equation: \begin{equation} (A_1 x + A) y^{''}(x) + (B_2 x^2 + B_1 x + B) y^{'}(x) + (C_2 x^2+C_1 x + C) y(x)=0 \end{equation} Then by using methods from the answer to the question quoted above and in references therein we obtained the following solution of the ODE above. We have: \begin{eqnarray} y(x)= \exp\left\{-\frac{2 A_1 x (A_1 B_1-A B_2)+A_1^2 B_2 x^2}{4 A_1^3}\right\}\left( {\mathfrak C_1} D_{-1+Q_1}(Q_2(x)) + {\mathfrak C_2} D_{-Q1}(\imath Q_2(x))\right) \end{eqnarray} where \begin{eqnarray} Q_1 &=& \frac{B_2^2 C_1 - B_1 B_2 C_2 +A_1 C_2^2}{B_2^3}\\ Q_2(x) &=& \frac{-A B_2^2 - 2 A_1^2 C_2 + A_1 B_2 (B_1 + B_2 x)}{A_1^{3/2} B_2^{3/2}} \end{eqnarray} and $D_\nu(x)$ are the parabolic cylinder functions https://en.wikipedia.org/wiki/Parabolic_cylinder_function . Those functions are special fuctions which are essentially related to the hypergeometric functions.
As usual I enclose a Mathematica code snippet that verifies the solution:
In[10]:= Clear[y]; x =.;
{A, A1, B2, B1, C2, C1} = RandomInteger[{1, 10}, 6];
{CC, B} = {(A C1)/A1 - (A^2 C2)/A1^2, (A B1)/A1 - (A^2 B2)/A1^2};
Q1 = (B2^2 C1 - B1 B2 C2 + A1 C2^2)/B2^3;
Clear[Q2];
Q2[x_] = (-A B2^2 - 2 A1^2 C2 + A1 B2 (B1 + B2 x))/(
A1^(3/2) B2^(3/2));
y[x_] = E^(-((2 A1 (A1 B1 - A B2) x + A1^2 B2 x^2)/(
4 A1^3))) (C[2] ParabolicCylinderD[-Q1, I Q2[x]] +
C[1] ParabolicCylinderD[-1 + Q1, Q2[x]]);
FullSimplify[((A1 x + A) D[y[x], {x, 2}] + (B2 x^2 + B1 x + B) D[y[x],
x] + (C2 x^2 + C1 x + CC) y[x])]
Out[17]= 0
Update: Now let $A$, $A_1$,$B_2$,$B_1$,$B$ and $C_1$ be real numbers and let: \begin{eqnarray} C &=& \frac{(A_1 B- A B_1)(A_1 B_1 - 2 A B_2)}{2 A_1^3} + \frac{A}{A_1} C_1\\ C_2 &=& \frac{B_2(A_1 B_1-2 A B_2)}{2 A_1^2} \end{eqnarray} Then the ODE in question is solved by: \begin{eqnarray} y(x) := \exp\left\{-\frac{(A_1 B_1-2 A B_2) x}{2 A_1^2}\right\}\cdot \left( {\mathfrak C}_1 U(Q_1,\frac{1}{2}+Q_2,-\frac{B_2(A+A_1 x)^2}{2 A_1^3}) + {\mathfrak C}_2 L_{-Q_1}^{-\frac{1}{2}+Q_2}(-\frac{B_2(A+A_1 x)^2}{2 A_1^3}) \right) \end{eqnarray} where \begin{eqnarray} Q_1 &=& \frac{-A_1^2 B_1^2+4 A^2 B_2^2+4 A_1^3 C_1}{8 A_1^3 B_2}\\ Q_2 &=& \frac{A_1^2 B - A A_1 B_1 + A^2 B_2}{2 A_1^3} \end{eqnarray} and $U(\cdot,\cdot,x)$ and $L_{\cdot}^{\cdot}(x)$ are the confluent hypergeometric function and the generalized Laguerre polynomial respectively.
Again, the Mathematica code snippet verifies the solution:
In[73]:= Clear[y]; x =.;
{A, A1, B2, B1, B, C1} = RandomInteger[{1, 10}, 6];
{CC, C2} = {((A1 B - A B1) (A1 B1 - 2 A B2))/(2 A1^3) + (A C1)/A1, (
B2 (A1 B1 - 2 A B2))/(2 A1^2)};
{Q1, Q2} = {(-A1^2 B1^2 + 4 A^2 B2^2 + 4 A1^3 C1)/(8 A1^3 B2), (
A1^2 B - A A1 B1 + A^2 B2)/(2 A1^3)};
y[x_] = E^((- (A1 B1 - 2 A B2) x)/(
2 A1^2)) (C[1] HypergeometricU[Q1,
1/2 + Q2, -((B2 (A + A1 x)^2)/(2 A1^3))] +
C[2] LaguerreL[-Q1, -(1/2) + Q2, -((B2 (A + A1 x)^2)/(2 A1^3))]);
FullSimplify[((A1 x + A) D[y[x], {x, 2}] + (B2 x^2 + B1 x + B) D[y[x],
x] + (C2 x^2 + C1 x + CC) y[x])]
Out[78]= 0
The lesson from those examples is the following. By using appropriate substitutions we manage to reduce a linear second order ODE with polynomial coefficients of order not bigger than two to hypergeometric functions. This was only possible subject to certain constraints on the coefficients of the polynomials in question.
My question is now what happens if those constraints are waived? Is it always possible to reduce solutions of that type of ODEs through hypergeometric functions or instead do we need some other class of functions to handle the generic case?
It is important to note that your procedure above is only suitable for the cases when $A_1\neq0$ and $B_2\neq0$ , otherwise your should need alternative analysis.
When $A_1=0$ and $A\neq0$ and $B_2=0$ , the ODE becomes
$Ay''+(B_1x+B)y'+(C_2x^2+C_1x+C)y=0$
Which belongs to an ODE of the form http://eqworld.ipmnet.ru/en/solutions/ode/ode0205.pdf.
When $A_1=0$ and $A\neq0$ and $B_2\neq0$ , the ODE becomes
$Ay''+(B_2x^2+B_1x+B)y'+(C_2x^2+C_1x+C)y=0$
Let $y=e^{kx}u$ ,
Then $y'=e^{kx}u'+ke^{kx}u$
$y''=e^{kx}u''+ke^{kx}u'+ke^{kx}u'+k^2e^{kx}u=e^{kx}u''+2ke^{kx}u'+k^2e^{kx}u$
$\therefore A(e^{kx}u''+2ke^{kx}u'+k^2e^{kx}u)+(B_2x^2+B_1x+B)(e^{kx}u'+ke^{kx}u)+(C_2x^2+C_1x+C)e^{kx}u=0$
$Au''+(B_2x^2+B_1x+2Ak+B)u'+((B_2k+C_2)x^2+(B_1k+C_1)x+Ak^2+Bk+C)u=0$
Choose $B_2k+C_2=0$ , i.e. $k=-\dfrac{C_2}{B_2}$ , the ODE becomes
$Au''+\left(B_2x^2+B_1x+\dfrac{BB_2-2AC_2}{B_2}\right)u'+\left(\dfrac{B_2C_1-B_1C_2}{B_2}x+\dfrac{AC_2^2-BB_2C_2+B_2^2C}{B_2^2}\right)u=0$
$u''+\left(\dfrac{B_2}{A}x^2+\dfrac{B_1}{A}x+\dfrac{BB_2-2AC_2}{AB_2}\right)u'+\left(\dfrac{B_2C_1-B_1C_2}{AB_2}x+\dfrac{AC_2^2-BB_2C_2+B_2^2C}{AB_2^2}\right)u=0$
Which relates to Heun's Triconfluent Equation.
And so on......