The following equation: $y''+y=\cos(x)$
Solving $y''+y=0$ gives me $c_1\cos(x)+c_2\sin(x)$
Using the particular integral yp form of $a\cos(x)+b\sin(x)$ and substituting this back into the ODE
$y = a\cos(x)+b\sin(x)$, $y'=-a\sin(x)+b\cos(x)$, $y''=-a\cos(x)-b\sin(x)$
Plugging this back into the ODE leaves me with $0=\cos(x)$
So how is the particular solution $y=1/2x\sin(x)$ with the coefficients value of $c_1=0$ and $c_2=1/2$, and where does the $x$ come from?
Observe that $y''+y = 0 \Rightarrow y=c_1 \cos(x) + c_2 \sin(x)$. So your forcing term $f(x) = \cos(x)$ is a solution to the homogenous solution, so we need to come up with a new basis for the method of undetermined coefficients. Since equating coefficients will fail for this basis since if $y=c_1 \cos(x) + c_2 \sin(x)$, the left hand side will always be a $0$ sicne it's a solution to the homogenous equation .The main way is to differentiate the homogenous solution $y_h$ with respect to $r$ where $r$ is the root of the characteristic polynomial. For this case,
$y(x) = c_1e^{rx} + c_2e^{-rx}, r = i$, so $\frac{dy}{dr} = xy_h(x) = x(\alpha_1\cos(x) + \alpha_2\sin(x))$ after the usual linear combination rearrangement trick for $e^{ix},e^{-ix}$ using Euler's identity. So our new basis for trial solutions $x(\alpha_1\cos(x) + \alpha_2\sin(x))$ which after equating coefficients will give you $\alpha_1 = 0, \alpha_2 = \frac{1}{2}$. Remember to add in the homogenous solution at the end.