Particular solution of the inhomogeneous equation by using the method of undetermined coefficients $$y_2^{\prime \prime} +y_2= -g_2p_1^2 \cos ^2 \tau + \omega_1p_1 \cos\tau $$
the differentiation with respect to time. 
Solution of the homogeneous term = $A  \cos\tau+ B \sin\tau$.
Now I want to find out out the particular solution. What would be the guess?
Or can you solve the particular solution?
$\omega_1, p_1 , g_2$ are constants.
 A: You can use variational of parameters method, since the Wronskian equals $1$ which makes the calculations easy. Here is the final result
$$ y \left( \tau \right) = A\cos \left( \tau \right)+B\sin\left( \tau \right)
+\frac{b\tau}{2}\,\sin \left( \tau \right) - 
\frac{a}{3}  \cos \left( \tau \right)^{2}+\frac{b}{2}\cos \left( 
\tau \right) +\frac{2a}{3} ,$$
where $a=-g_2\,p^2_1,\,$ $b= \omega_1\,p_1$.
A: Call the right-hand side $-a\cos^2\tau+b\cos\tau$. If we can find particular solutions of (i) $y''+y =\cos^2\tau$ and of (ii) $y''+y=\cos\tau$, we can deal with our right-hand side by linearity.
(i) Recall that $\cos^2\tau=\frac{1}{2}(1+\cos 2\tau)$. A particular solution of $y''+y=\frac{1}{2}$ is easy: just let $y=\frac{1}{2}$.  
Next we deal with $\frac{1}{2}\cos 2\tau$. Look for a solution $y$ of shape $k\cos 2\tau$. 
Then $y''=-4k\cos 2\tau$ and $y=k\cos 2 \tau$, so we want $-3k=\frac{1}{2}$, giving $k=-\frac{1}{6}$.
That takes care of the $\cos^2\tau$ term. It remains to deal with $\cos\tau$. 
(ii) There is a standard trick in this case. We look for a solution $y$ of shape $A\tau\sin\tau$. Then $y'=A\tau\cos\tau+A\sin\tau$. Differentiating again we get $y''=-A\tau\sin\tau+2A\cos\tau$. Add $y$ to this and we get $y''+y=2A\cos\tau$. It follows that $A=\frac{1}{2}$.
So a particular solution of $y''+y=\cos\tau$ is $\frac{1}{2}\tau\sin\tau$.
We have mentioned all the components you need to write down a particular solution. 
