undetermined coefficients. What am I doing wrong? I am having some trouble to solve the following differential equation for the undetermined coefficient:
$$
y''+2y'+y=xe^{-x}
$$
I have been watching some videos on youtube and done some reading but still do not fully understand what must be done to solve it. I was able to solve the left side by getting the common roots:
$$
(x+1)^{2} = r^{2}+r+1
$$
roots are -1, so
$$
y=(A+Bx)e^{-x}
$$
Now after I found the left side I started to determine $$g(x)$$
so $$g(x)=xe^{-x}$$
$$yp = e^{-x}Ax+e^{-x}B$$
derivative of yp is
$$y'p=-e^{-x}Ax+e^{-x}A-e^{-x}B$$
double derivative of yp is
$$y''p=e^{-x}Ax-2Ae^{-x}+Be^{-x}$$
I then subbed these into the original equation:
$$
(e^{-x}Ax-2Ae^{-x}+Be^{-x}) + 2(-e^{-x}Ax+e^{-x}A-e^{-x}B) + (e^{-x}Ax+e^{-x}B)=xe^{-1}
$$
Now after factoring everything out I got that $$A=\frac{1}{2}e^{-x}$$
Which would bring me to my final answer of $$y=Ae^{-x}+Bxe^{-x}+\frac{1}{2}e^{-x}$$
However this is wrong as the final answer is actually  $$y=Ae^{-x}+Bxe^{-x}+\frac{1}{6}x^{3}e^{-x}$$
What is it that I am doing wrong? I am not sure what else to do :(
Thank you :)
 A: There's an error in your expansion of the long formula, it actually simplifies to $0=xe^{-x}$. This is because what you did is take a generic homogeneous solution for your particular solution ($y_p$ has the same form as $y$ above). Note that the linear combinations of $e^{-x}$ and $xe^{-x}$ solve
$$y'' + 2y' + y = 0$$
and thus there's no way a function of the same form would satisfy
$$y'' + 2y' + y = xe^{-x}.$$
Also note that even if it was right, $A$ can not be a function of $x$. These coefficients are always meant to be constants.
You need to look for $y_p$ in a different form. There's a polynomial of first order in the RHS, so we will need to determine two unknowns indeed. However, they will not stand by the functions $e^{-x}$ and $xe^{-x}$ as both of these have already been used in the fundamental system. In such cases, where the exponent in the RHS is one of the roots of your characteristic polynomial, you need to go higher with the power of the $x$ prefactors—the rule of thumb being just high enough to prevent collision with the fundamental system, i.e., starting with $x^2 e^{-x}$.
Short answer: look for $y_p$ in the form
$$C x^2 e^{-x} + D x^3 e^{-x}.$$
A: Hint: $y_p=(Ax^2+Bx^3)e^{-x}.$ Your characteristic equation is $(r+1)^2=0$. Thus $e^{-x}$ and $xe^{-x}$ are solutions of homogeneous equation. The UC set of the inhomogeneous part is $\{e^{-x}, xe^{-x}\}$, so you should multiply each element of this set by $x^2$. You may also use the annihilator method by operating either side with $(D+1)^2$ to kill the function on the RHS.
A: You have an inhomogeneous differential equation $y'' + 2y' + y = xe^{-x}$. To solve these we apply the following steps:
1) Find the general solution to the homogeneous equation $y'' + 2y' + y = 0$.
2) Find one solution $y = p(x)$ to the equation $y'' + 2y' + y = xe^{-x}$.
3) Then any solution to the equation $y'' + 2y' + y = xe^x$ is of the form $y = p(x) + h(x)$, where $h(x)$ is a solution to the homogeneous equation $y'' + 2y' + y = 0$.
You have correctly solved step 1), the general solution to the equation $y'' + 2y' + y = 0$ is $y(x) = Ae^{-x} + Bxe^{-x}$. Next, you want to find a solution to the equation $y'' + 2y' + y = xe^{-x}$. To do this, we often "guess" the form of the solution to be similar to the right hand side. In this case the right hand side is $e^{-x}$ multiplied by a polynomial. You could "guess" $p(x)$ to be of the form $p(x) = e^{-x} (ax^3 + bx^2)$. We are taking degree $3$ here, because we take two derivatives at most, and we end up with a linear term. So we probably won't need any higher degree terms. There is no need to look at linear and constant terms, because they satisfy the homogeneous equation.
Now we have to compute $p'' + 2p' + p$. We compute $p' = e^{-x} \left(3ax^2 + 2bx - (ax^3 + bx^2)\right)$ and $p'' = e^{-x} \left(ax^3 + bx^2- 2(3ax^2 + 2bx) + 6ax + b \right)$. So we get $p'' + 2p' + p = e^{-x} \left(x^3(a -2a + a) + x^2(b +  2(-b+3a) + (b - 6a)) + x(2 \cdot 2b - 4b + 6a) + 2b \right) = (6ax+2b) e^{-x}.$
This should equal $xe^{-x}$, and so we find $a = \frac{1}{6}, b=0$ and $p(x) = \frac{1}{6} x^3 e^{-x}$. Now we can finally write down the general solution to the inhomogeneous equation $y'' + 2y' + y = xe^{-x}$, which is $y(x) = \frac{1}{6} x^3 e^{-x} + Ae^{-x} + Bxe^{-x}$.
