Linear 1st order differential equation I tried to solve this equation but need help from seniors what to do next... 
$$\frac{dq}{dt} + q = 4\cos2t ; q(0) =1 $$
Multiplying both sides by I(t) i.e.
$$I(t)= e^t$$
$$e^t\frac{dq}{dt} + e^t q =4e^t \cos2t$$
$$\frac{d}{dt}(e^tq) = 4e^t\cos2t$$
Integrating both sides
$$e^t q = 4\int e^t \cos2t dt  $$
Now I don't know how to integrate the right side of above equation..
 A: Simple use of integration by parts:
Say,
$$\begin{align} \\ & I=\int e^t \cos2t \, dt
 \\ & =\cos2t \int e^t \,  dt - \int \left\{\frac{d}{dt}(\cos2t)\int e^t \,  dt\right\}\, dt
 \\ & =e^t\cos2t +2 \int e^t\sin2t  \, dt
 \\ & =e^t\cos2t +2 \left[\sin2t \int e^t \,  dt - \int \left\{\frac{d}{dt}(\sin2t)\int e^t \,  dt\right\}\, dt\right]
 \\ & =e^t\cos2t +2 \left[e^t \sin2t - 2\int e^t\cos2t  \, dt\right]
 \\ & =e^t\cos2t + 2e^t \sin2t - 4I\end{align}$$
Therefore, we have that 
$$5I=e^t\cos2t + 2e^t \sin2t$$
Hope this helps you.
A: If you're familiar with the definitions of sine and cosine in terms of complex exponentials:
$$
\cos \theta = \frac{1}{2} (e^{i\theta} + e^{-i\theta}), \qquad \sin \theta = -\frac{i}{2} (e^{i\theta} - e^{-i\theta}),
$$ 
then a quick detour into the complex plane allows you to solve this without integration by parts:
\begin{align}
\int e^t \cos 2t \,dt &= \frac{1}{2} \int e^t \left( e^{2it} + e^{-2it} \right) dt \\
&= \frac{1}{2} \int e^{(1 + 2i) t} + e^{(1 - 2i) t} dt \\
&= \frac{1}{2} \left[ \frac{e^{(1 + 2i) t}}{1 + 2i} + \frac{e^{(1 - 2i) t}}{1 - 2i}\right] \\
&= \frac{1}{2} e^t \frac{(1 - 2i) e^{2it} + (1 + 2i) e^{-2it}}{(1 + 2i)(1 - 2i)} \\
&= \boxed{\frac{1}{5} e^t \left[ \cos 2t + 2 \sin  2t \right]}
\end{align}
I suspect that if you're taking a class in ODEs that you'll have to start using complex numbers soon enough, so you might as well get used to it.
A: Laplace-transforming both sides of the ODE,
$$s Q (s) - q_0 + Q (s) = \dfrac{4s}{s^2+4}$$
Since the initial condition is $q_0 = 1$, we have
$$Q (s) = \dfrac{1}{s+1} + \dfrac{4s}{(s+1)(s^2+4)} = \dfrac{1}{5}\left(\dfrac{1}{s+1}\right) + \dfrac{4}{5} \left(\dfrac{s}{s^2+4}\right) + \dfrac{8}{5} \left(\dfrac{2}{s^2+4}\right)$$
Taking the inverse Laplace transform,
$$q (t) = \frac{1}{5} \, e^{-t} + \frac{4}{5} \, \cos(2t) + \frac{8}{5} \, \sin (2t)$$
