Solving second order ODE with undetermined coefficients How come the particular solution to $$y''+4y=\cos(2x)$$
is of the form $$y=x(a\sin(2x)+b\cos(2x))?$$
More specifically, why do you need to multiply with $x$? 
 A: I don't know how helpful this will be, but here's one way to think about this problem. If you were given $$y''+4y = 0$$ you might be able to piece together the solution by realizing that the second derivative of sine is negative sine, and the second derivative of cosine is negative cosine. Then realizing that if the argument inside each trig function is $2x$, then a second derivative will put a coefficient of $4$ in front of each one. Lastly, you can observe this is all true regardless of which coefficients $a,b$ respectively are attached to sine and cosine. So, $$y = a\sin(2x)+b\cos(2x)$$ is a reasonable guess for a solution to $y''+4y = 0$. In fact, it will satisfy the differential equation. However, the equation $y''+4y = \cos(2x)$ is clearly different. We can use it to raise the question "how can I differentiate a function $y$ twice, add it to $4y$ and be left with $\cos(2x)$?" This is where you want to consider multiplying $x$ by some function, because the derivative of $x\cdot f(x)$ is $ xf'(x)+f(x)$. Multiplying $f(x)$ by $x$ and differentiating will separate off an $f(x)$ term. This is an important observation, and ultimately is why you want to multiply something by $x$; it is what will leave you with remaining terms when the differentiation is complete, which is what is happening in your equation. The second derivative of $xf(x)$ is $xf''(x)+2f'(x)$. That is to say, we see that the quantity $2f'(x)$ remains, just as the quantity $\cos(2x)$ remains in the differential equation. Setting them equal we have $$2f'(x) = \cos(2x) \\ \implies f'(x) = \frac{1}{2}\cos(2x) \\ \implies f(x) = \frac{1}{4}\sin(2x) \\ \implies xf(x) = \frac{x}{4}\sin(2x)$$ Now you can try using $y(x) =  a\sin(2x)+b\cos(2x)+\frac{x}{4}\sin(2x)$ and evaluating the quantity $y''+4y$. You should get the correct result. I realize my answer isn't rigorous by any means, and my differential equation skills are pretty rusty. But that's how I would think about your question and get to an answer.
A: one way to see that a particular solution of $$y'' + 4y = \cos 2x $$ is a multiple of $x\sin 2x $ is to look at a particular solution $$y = \frac{\cos 2x - \cos (2x + 2\epsilon x)}{8\epsilon + 4\epsilon^2}= \frac{x\sin 2x}{4}+\cdots\to \frac{x\sin 2x}{4} \text{ as } \epsilon \to 0. $$ of $$y'' + 4y = \cos(2x + 2\epsilon x) $$
