What is the proof of this property of integrals involving $e?$ I was reading my calculus book wherein I came across a note, being worth of attention. It says:

Integrals in the form of $\int P(x)e^{ax}dx$ have a special property. After calculating the integral, we obtain a function in the form of $Q(x)e^{ax}$ where $Q(x)$ is a polynomial of the same degree as of $P(x)$. This is called method of indefinite coefficients.

Like for example, we do $\displaystyle\int (3x^3-17)e^{2x}dx$, We can do it traditionally by integration by parts but let me show you my or rather author's method :
Let this be equal to $(Ax^3+Bx^2+Cx+D)e^{2x}$
Now differentiating both sides we get, $$(3x^3-17)e^{2x}=2(Ax^3+Bx^2+Cx+D)e^{2x}+e^{2x}(3Ax^2+2Bx+C)$$
Now we will cancel $e^{2x}$ on both sides and the rest is equating the coefficients.
I have seen that this property is applicable in every question but I don't know the mathematical proof of this. It wasn't even in the book.
Any help regarding the proof is greatly appreciated.
 A: The statement

$\int P(x) e^{ax}\, \mathrm{d}x = Q(x) e^{ax}$ with $\deg(P(x)) = \deg(Q(x)) $

is equivalent (by the definition of antiderivative) to showing that
$$
\frac{\mathrm{d}}{\mathrm{d}x}Q(x) e^{ax} = P(x) e^{ax}
$$
where $\deg(P(x)) = \deg(Q(x)) $.
Thus, writing $Q(x) = \sum_{k=0}^\color{blue}{n} c_k x^k$ for some constants $c_k$ with $c_n \neq 0$ then $\deg(Q(x)) = \color{blue}{n}$. So we get
\begin{align}
\frac{\mathrm{d}}{\mathrm{d}x}Q(x) e^{ax}  & =\frac{\mathrm{d}}{\mathrm{d}x}\left( c_0 e^{ax} +\sum_{k=1}^n c_k x^ke^{ax}\right)\\
& =ac_0e^{ax} +\sum_{k=1}^n c_k \left( kx^{k-1} e^{ax} + x^kae^{ax}\right)\\
& \overset{\color{purple}{k-1\to k}}{=} \left(ac_0+ \sum_{k=\color{purple}{0}}^{\color{purple}{n-1}} c_{k+1} (k+1) x^{k} +\sum_{k=1}^n c_k ax^k\right) e^{ax}\\
& = \underbrace{\left(\sum_{k=0}^{n}C_k x^k\right)}_{P(x)} e^{ax}
\end{align}
where
$$
C_k =\begin{cases}
a c_0 + c_1, & k=0\\
c_{k+1}(k+1) + c_ka, & 1\le k \le n-1\\
c_ka, & k=n 
\end{cases}
$$
and since $C_n = c_n a \neq 0$ then $\deg(P(x)) = n$ as well.
A: The best method for this question is to use induction and integration by parts (as suggested by W. Fan), as well as the linearity of the integral. Note that if $P(x) = c_n x^n + \cdots + c_0$,
$$\int P(x) e^{ax} dx = \int (c_n x^n + \cdots + c_0) e^{ax} dx $$
$$= \sum_{i=0}^n c_k\int x^ke^{ax}dx$$
Thus, it suffices to show that the result holds for $x^k$. We do this by induction on $k$. The basis for $k=0$ is simple to verify. Now consider, for $k$ in general, the integral:
$$\int x^k e^{ax} dx$$
$$\frac{1}{a}x^ke^{ax} -\frac{k}{a}\int x^{k-1}e^{ax} dx$$
for $a \neq 0$. This latter integral is $e^{ax}$ multiplied by a polynomial of degree $(k-1)$ by the induction hypothesis, so it follows that $\int x^k e^{ax} dx$ is $e^{ax}$ multiplied by a polynomial of degree $k$. $\square$
Remark: note that the statement is not true for $a \neq 0$ (by direct verification). The statement is also missing the clause that $Q(x)e^{ax}$ is the antiderivative up to a constant, which is apparent when verifying the basis.
This argument also gives $Q$ explicitly with a little bit more effort. As an exercise, show that:
$$Q(x) = \sum_{k=0}^n  c_k \bigg(\frac{1}{a}x^k-\frac{k}{a^2}x^{k-1}+\frac{k(k-1)}{a^3}x^{k-2}+\cdots +{(-1)}^k\frac{k!}{a^{k+1}} \bigg)$$
where $P(x) = c_n x^n + \cdots + c_0$ as before.
A: The problem reduces to finding the polynomial $Q$ of degree $n = \deg P$ such that $P = aQ + Q'$.
Differentiating $n$ times and eliminating $Q', Q'', \dots, Q^{(n)}$ between the equations gives:
$$
\require{cancel}
\begin{align}
P &= aQ + \color{red}{\bcancel{Q'}}
\\ P' &= \color{red}{\bcancel{aQ'}} + \color{blue}{\bcancel{Q''}} \quad &&\big|\;\cdot \color{red}{\frac{-1}{a}}
\\ P'' &= \color{blue}{\bcancel{aQ''}} + \bcancel{Q'''} \quad &&\big|\;\cdot \color{blue}{\frac{+1}{a^2}}
\\ \dots
\\ P^{(n)} &= \bcancel{aQ^{(n)}} + \xcancel{Q^{(n+1)}} \quad &&\big|\;\cdot \frac{(-1)^n}{a^n}
\\ \hline
P - \frac{1}{a} P' + \frac{1}{a^2} P'' - \dots + (-1)^n \frac{1}{a^{n}} P^{(n)} &= aQ
\end{align}
$$
$$
\iff\quad Q = \frac{1}{a} P - \frac{1}{a^2} P' + \frac{1}{a^3} P'' - \dots + (-1)^n \frac{1}{a^{n+1}} P^{(n)}
$$
