Finding the solution to the ODE $y^{(n)}=xe^x$ I'm trying to find the solution to the ODE $y^{(n)}=xe^x$ , $-\infty<x<\infty$.
First I found the general solution to the homogenous equation $y^{(n)}=0$
The characteristic polinomial is $l(r)=r^n$, from which we get n solutions: $1, x, x^2, ... , x^{n-1}$.
So by the theorem of parameter variation, there's a private solution to the non homogenic equation, of the form $y_p(x)=\sum_{i=1}^n c_i(x)x^{i-1}$ which meets the conditions:
$\displaystyle\sum_{i=1}^n c_i'(x)x^{i-1}=0$
$\displaystyle\sum_{i=1}^n c_i'(x)(i-1)x^{i-2}=0$
$\displaystyle\sum_{i=1}^n c_i'(x)(i-1)(i-2)x^{i-3}=0$
$\vdots$
$\displaystyle\sum_{i=1}^n c_i'(x)(i-1)(i-2)...(i-n+1)x^{i-n}=xe^x$
To solve this for $\{c_i'\}_{i=1}^n$, I tried looking at the corresponding matrix, using Cramer's rule from linear algebra (because the determinants looked nice), but didn't manage to completely solve it.
Any tips?
 A: To solve $y' = xe^x$, integrate by parts to conclude that
$$y(x) = xe^x - e^x + c$$
To solve $y'' = xe^x$, integrate once by parts to conclude that
$$y'(x) = xe^x - e^x + c$$
Integrate again to find
$$y(x) = xe^x - 2e^x + c_1 x + c_2$$

Repeat this process as needed, and the conclusion is that the general solution of $y^{(n)}(x) = xe^x$ is
$$y(x) = xe^x - ne^x + P_{n - 1}(x)$$
where $P_{n - 1}$ is a polynomial of degree at most $n - 1$. Notice that this polynomial has $n$ coefficients, so we've found $n$ linearly independent solutions (namely $xe^x - ne^x + c_k x^k$ for each $k$).
A: The matrix is triangular so Cramer's rule seems a bit heavy-handed. The last equation gives you $c_n'(x)=\frac1{(n-1)!}xe^x,$ and from there all the other $c_i'(x)$ will be polynomials multiplied by the exponential.
In general, the differential equation $(f(x)e^x)'=Q(x)e^x$ reduces to finding a polynomial $f$ with $f+f'=Q(x)$ (we discard the negative exponential that solves the homogeneous case). For a monomial $Q(x)=x^n$ this is $f(x)=x^n-nx^{n-1}+n(n-1)x^{n-2}-\ldots$ and by linearity this solves the case for general $Q.$
A: Try by differentiation,
$$z=xe^x,\\
z'=e^x+xe^x,\\
z''=e^x+e^x+xe^x=2e^x+xe^x\\
\cdots$$
The pattern is obviously $z^{(n)}=ne^x+xe^x$, so you are integrating
$$y^{(n)}=\left(xe^x\right)^{(n)}-ne^x.$$
