# Existence of polynomial solutions to second order ODEs

Consider a second order ODE of the form,

$$p(x)~ y^{\prime \prime}+ q(x)~ y^\prime + r(x)~ y = 0 ,$$

where $$p,q,r$$ are polynomials. Many important differential equations in science take this form. But the nature of their solutions vary.

In the case of the Chebyshev differential equation the solutions are Chebyshev polynomials. But for the case of the Bessel differential equation the solutions are Bessel functions which are represented by an infinite series. I have two questions regarding ODEs of the form stated above.

1. What are the conditions on $$p, q, r$$ such that the solution to the equation is a polynomial and not an infinite series ?
2. Can every polynomial be constructed as a solution to such an equation ? What would be $$p, q, r$$ in terms of the desired polynomial.

By writing a trial solution of the form $$y = \sum_{k= 0}^{\infty} a_k x^k$$ I was able guess that the solution to the first question can be reduced some kind of eigenvalue problem. But that's as far as I got. Surely these kind of questions have been investigated before in literature.

Question 1. It is easy give some necessary conditions. If $$\operatorname{deg}(r)=d\ge0$$, then $$\operatorname{deg}(q)=d+1$$ and $$\operatorname{deg}(p)=d+2$$. Let $$r(x)=r_dx^d+\dots$$, $$q(x)=q_{d+1}x^{d+1}+\dots$$ and $$p(x)=p_{d+2}x^{d+2}+\dots$$, and let $$n$$ be the degree of $$y$$. Then $$n(n-1)\,p_{d+2}+n\,q_{d+1}+r_d=0.$$
Question 2. The answer is yes. Take for instance \begin{align} p(x)&=y(x),\\ q(x)&=y(x),\\ r(x)&=-y'(x)-y''(x). \end{align}