# Solution to Differential equation 2nd order, x*e^x

I'm trying to solve the following differential equation:

$$y'' + y = x \cdot e^x$$

I already have the homogeneous solution: $$y_h = c_1 \cdot cos(x) + c_2 \cdot sin(x)$$ but I'm struggeling to find the particular solution. I tried using $$y_p = a \cdot x \cdot e^x$$ but that didn't quite work, or maybe I did something wrong...

Can somebody explain to me how to solve this?

Thanks.

Edit: Here's the solution:

$$y_p = (a \cdot x + b) \cdot e^x$$

$$y_p' = (a + a \cdot x + b) \cdot e^x$$ and $$y_p'' = (2 \cdot a + a \cdot x + b) \cdot e^x$$

$$y_p'' + y_p = (2 \cdot a \cdot x + 2 \cdot a + 2 \cdot b) \cdot e^x$$

$$\Rightarrow 2 \cdot a = 1 \Rightarrow a = \frac{1}{2}$$ and $$2 \cdot a + 2 \cdot b = 0 \Leftrightarrow 2 \cdot a = 1 = - 2 \cdot b \Rightarrow b = - \frac{1}{2}$$

$$\Rightarrow y_p = (a \cdot x + b) \cdot e^x = \frac{x-1}{2} \cdot e^x$$

All in all: $$y = y_h + y_p = c_1 \cdot cos(x) + c_2 \cdot sin(x) + \frac{x-1}{2} \cdot e^x$$

Try $$y_p = (ax+b)e^x$$.