How to solve $ y''+2y'+4y=xe^x $? After having the two complex roots of the equation, I get the homogeneous equation below:
$y_h=(c_1\cos(2x)+c_2\sin(2x)) e^{-x} $
We can guess that the particular solution will be of the form:
$y_p=(A\cos(2x)+B\sin(2x))e ^{-x}$
Then:
$y'_p=(-2A\sin(2x)+2B\cos(2x)) e ^{-x} - (A\cos(2x)+B\sin(2x)) e ^{-x}$
And so :
$y'_p=(-2A\sin(2x)-A\cos(2x) - B\sin(2x)+2B\cos(2x)) e ^{-x}$
then the second derivative :
$y''p= -(-2A\sin(2x)-A\cos(2x) - B\sin(2x)+2B\cos(2x)) e ^{-x}$
And so :
$y''p= (4A\sin(2x)-3A\cos(2x) - 3B\sin(2x)-4B\cos(2x)) e ^{-x}$
By replacing the terms of the initial equation :
$(4A\sin(2x)-3A\cos(2x) - 3B\sin(2x)-4B\cos(2x)) e ^{-x}. + 2(-2A\sin(2x)-A\cos(2x) - B\sin(2x)+2B\cos(2x)) e ^{-x} + 4(A\cos(2x)+B\sin(2x)) e ^{-x}=xe^x$
By developing I obtain the terms below, however I do not see how to find A and B in a system.
$-3A\cos(2x)-3B\sin(2x) + 4A\cos(2x)+4B\sin(2x)=xe ^2x$
Is there something I missed?
The solution h says that we can verify $h (0) = 1$ and $h (1) = 0$. Having said that, how do you reach this conclusion?
 A: $$y′′+2y'+4y=xe^x$$
Your $y_h$ is not correct:
$$r^2+2r+4=0$$
$$(r+1)^2+3=0$$
$$r=-1\pm i \sqrt 3$$
$$y_h=e^{-x}(c_1  \cos (\sqrt 3x)+c_2 \sin (\sqrt 3 x))$$
Then for the particular solution try:
$$y_p=(ax+b)e^x$$
A: To avoid complicated computations, the best way is to begin by eliminating the term $ e^x$ which makes repetition.
Put $$ y=ze^x$$
So
$$y'=(z'+z)e^x\;\;,\; $$
$$y''=(z''+2z'+z)e^x$$
The equation
$$y''+2y'+4y=xe^x,$$
becomes
$$z''+4z'+7z=x$$
A particular solution is $ z_p=\frac 17x-\frac{4}{49}$.
thus
$$y_p=z_pe^x=\frac{1}{49}(7x-4)e^x$$
A: There's a Differential Operator approach. Let $\hat{D}$ mean take the first derivative of the function to the right.
Then $y''+2y'+4y=(\hat{D}^2+2\hat{D}+4)y=xe^x$.
The method of characteristic equations combined with the operator approach can facilitate a rapid solution.
Assume $y=e^{kx}$ for some $k$.
$(\hat{D}-p)y=(k-p)y=0$ iff $k=p$.
Thus $y=c_1e^{px}$ is a solution to $y'-py=0. $
More generally, an arbitrary poynomial in $\hat{D}$ corresponds to an associated characteristic polynomial in $k$ having the same coefficients. The solutions of the polynomial in $k$ are the power tos which to raise $e^x$ to get solutions to the homogeneous equation.
A modified approach can be used to solve certain inhomogeneous equations.
It can be shown that if $y_1$ solves $(\hat{D}-k)y=g(x)$, and a differential operator $\hat{P}$ is a polynomial in $\hat{D}$ such that $\hat{P}g=0$, then $\hat{P}(\hat{D}-k)y=0$ is now a homogeneous equation which solves the original in homogenous equation once the right coefficients are chosen.
Additionally, if $y_1$ is a solution of  $(\hat{D}-1)y=0$, then $x^py_1$ is a solution of $(\hat{D}-1)^py=0$.
Putting this all together we have:
$(\hat {D}-1)^2(\hat{D}^2+2\hat{D}+4)y=0$
With characteristic equation $(k-1)^2(k^2+2k+4)=0$.
This has solutions $k \in \{1,-1+i\sqrt{3}, -1-i\sqrt{3}\}$ where 1 has a multiplicity of 2.
From the above, this new homogeneous equation has solution:
$y=c_1e^x+c_2xe^x+c_3e^x\sin{\sqrt{3}x}+c_4e^x\cos{\sqrt{3}x}$
Now apply ($\hat{D}^2+2\hat{D}+4)$ to this y. We know that the second pair of terms becomes zero since its the general solution to the homogeneous equation.
Upon applying it to it to the first pair of terms, one gets:
$(7c_1+4c_2)e^x+7c_2xe^x$ which we require to be $xe^x$.
This requires the coefficient of $e^x$ to be 0 and the coefficient of $xe^x$ to be 1.
Solving the linear equations in two variables we get that $c_2=\frac{1}{7}$ and $c1=\frac{-4}{49}$ consistent with the other solutions above.
