If you look closely to your ODE's LH side, you discover that: $y^{(IV)}+2y^{\prime \prime}+y= (y^{\prime \prime} +y)^{\prime \prime} +(y^{\prime \prime}+y)\; .$ After the substitution $u=y^{\prime \prime} +y$, your ODE rewrites: $u^{\prime \prime} +u =\cos x\; ,$ which is a simple second order linear equation and thus can be solved explicitly with ease; in particular, after some computations, you find: $u(x)=A\ \cos x+ B\ \sin x + \frac{1}{2}\ x\ \sin x\; .$ Now you can return to the original unknown $y$: the only thing you have to do is to solve the ODE: $\tag{1} y^{\prime \prime} + y = A\ \cos x+ B\ \sin x + \frac{1}{2}\ x\ \sin x$ which is again a simple second order linear equation. In order to solve the latter ODE in a clever way, you can observe that $y$ solve (1) iff $y(x)=\bar{y}(x) + y_1(x) + y_2(x) + y_3(x)$ where $\bar{y}$ is the general solution of $\bar{y}^{\prime \prime} + \bar{y} =0$ (which will depend on two arbitrary constants $C,D\in \mathbb{R}$) and $y_1,\ y_2,\ y_3$ are particular solutions of: $y_1^{\prime \prime} +y_1 = A\cos x,\qquad y_2^{\prime \prime} +y_2=B\sin x ,\qquad y_3^{\prime \prime} + y_3=\frac{1}{2}x\sin x\; .$