Solve second-order ODE using gamma functions I would like to solve the ODE
$$\left(x-k_1\right)\frac{dY}{dx} + \frac{1}{a}x^2\frac{d^2 Y}{d x^2}-Y+k_2=0$$
with boundary conditions $Y\left(k_3\right)=0$ and $\frac{d Y}{d x}\left(\infty\right)=1-b$ (meaning if $x \to \infty$, the derivative approaches $1-b$). Not sure if it helps, but we also have $0\leq b \leq 1$, $a \geq 0$, and $k_2 + k_3 \leq k_1$. $x$ and $Y$ should also both be $\geq 0$.
I came across this equation years ago and remember that the solution involved gamma functions in some form, but otherwise I'm not sure where to start (or even what term to Google).
Would anyone know how to find the solution here?

You can solve this equation assuming it is a function of $x$ and $t$, but you will find that when constraining to the boundary conditions it is a function of $x$ only, so I'll treat it like an ODE.
For your question I will use the following trick: given a particular solution $u(x)$ to the homogeneous equation
\begin{align}
u''+f_1(x)u'+f_0(x)u=0,
\end{align}
the ODE
\begin{align}
y''+f_1(x)y'+f_0(x)y=f(x)
\end{align}
is exact under the integrating factor $e^{F_1}u$, where $F_1(x)=\smallint f_1(x)\mathrm dx$. Note that there is a term of the form $xy'-y$, so you should try to find a linear particular solution to your equation. We find that $Y_0=x-k_1$ works. So for your ODE
\begin{align}
Y''+a\frac{x-k_1}{x^2}Y'-\frac{a}{x^2}y+\frac{ak_1}{x^2}=0,
\end{align}
multiply by $(x-k_1)x^ae^{ak_1/x}$ to arrive at
\begin{align}
\left((x-k_1)x^ae^{ak_1/x}Y'-x^ae^{ak_1/x}Y\right)'+ak_1\frac{x-k_1}{x^2}e^{ak_1/x}=0.
\end{align}
Integrating and rearranging we arrive at
\begin{align}
Y'-\frac{1}{x-k_1}Y+\frac{k_1}{x-k_1}=\frac{c_1}{(x-k_1)x^ae^{ak_1/x}}.
\end{align}
This ODE is exact under the integrating factor $1/(x-k_1)$, multiplying, integrating, and rearranging we arrive at
\begin{align}
Y(x)=k_1+(x-k_1)\left(c_2+c_1\mathcal I(x)\right);\quad\left[\mathcal I(x)=\int\frac{\mathrm dx}{(x-k_1)^2x^ae^{ak_1/x}}\right].
\end{align}
We see that we recover the particular solution $Y_0=k_1+c(x-k_1)$ here as well. Now to fit the solution to the constraints. Evaluating $Y(x)$ at $k_3$ and letting $x\rightarrow\infty$ in $Y'(x)$ we get the equations
\begin{align}
\mathcal I(k_3)c_1+c_2&=\frac{k_1}{k_1-k_3},\\
\mathcal I(\infty)c_1+c_2&=1-b;\quad\left[\mathcal I(\infty)=\lim_{x\rightarrow\infty}\mathcal I(x)\right].
\end{align}
Which have the solutions
\begin{align}
c_1&=\frac{1}{\mathcal I(k_3)-\mathcal I(\infty)}\left(\frac{k_1}{k_1-k_3}+b-1\right),\\
c_2&=\frac{1}{\mathcal I(k_3)-\mathcal I(\infty)}\left(\frac{k_1}{k_1-k_3}\mathcal I(\infty)+(1-b)\mathcal I(k_3)\right).
\end{align}
So our solution is
\begin{align}
Y(x)=k_1+\frac{x-k_1}{\mathcal I(k_3)-\mathcal I(\infty)}\left((1-b)(\mathcal I(k_3)-\mathcal I(x))+\frac{k_1}{k_1-k_3}(\mathcal I(x)-\mathcal I(\infty))\right);\\\\\left[\mathcal I(x)=\int\frac{\mathrm dx}{(x-k_1)^2x^ae^{ak_1/x}}\right].
\end{align}
What I've been ignoring is the singularity in $\mathcal I(x)$. If the domain of $x$ includes $k_1$, the integral is divergent. This is why I ask if there are more constraints on your $k$'s! If we restrict our $x$ domain to $[k_3,\infty)$ (as your boundary conditions imply), then we require that $k_3>k_1$ for $x>k_1$.
