Solve differential equation $x' = 2x \cos^2 (t) + \sin (t)$. Looking for an error in my solution. I need to solve differential equation:  $$x' = 2x \cdot \cos^2 (t) + \sin (t)$$
Using the general formula of solution for ODE: $x′(t)+p(t)x(t)=q(t)$, we have that:

*

*$p(t) = -2\cos^2 (t)$

*$q(t) = \sin (t)$
Then we calculate integrating factor:
$$ \displaystyle I(t) = e^{\int p(t) dt} = \frac{1}{e^{\frac{\sin(2t)}{2} + t}}$$
So we get:
$\phi = e^{\frac{\sin(2t)}{2} + t} \cdot (\int \frac{\sin (t)}{e^{\frac{\sin(2t)}{2} + t}} dt) + C$
And I have no idea how to integrate that. I probably did something wrong.
 A: Using the integrating factors method, indeed as you said the differential equation has the form $$x'(t)+p(t)x(t)=q(t),$$ with,

*

*$p(t)=-2\cos^{2}(t)$,

*$q(t)=\sin(t)$.

The integrating factor is \begin{align*} \mu(t)&=e^{\int p(t)}\, {\rm d}t\\ &=\exp\left(\int -2\cos^{2}(t)\, {\rm d}t\right)\\ &=e^{-t-\cos(t)\sin (t)}.\end{align*}
Hence by the integrating factors method, the general solution is given by \begin{align*} x(t)&=\frac{1}{\mu(t)}\left(\int \mu(t)q(t)\, {\rm d}t+C \right)\\ &=\frac{1}{e^{-t-\sin(t)\cos(t)}}\left(\int e^{-t-\sin(t)\cos(t)}\sin(t)\, {\rm d}t+C \right).\end{align*}
Alternatively, we can use the variation of constants method, as follows:

*

*Solve the homogeneous equation $x'(t)+p(t)x(t)=0$, with solution \begin{align*} x(t)&=Ce^{\int -p(t)\, {\rm d}t}\\ &=Ce^{t+\sin(t)\cos(t)},\end{align*} with $C$ a constant of integration.


*Now we replace the constant $C$  with a certain function $C(t)$. By substituting this solution into the nonhomogeneous differential equation, we can determine the function $C(t)$. Then we can setting the general solution as $x(t)=C(x)e^{\int-p(t)\, {\rm }t}$. Then $C'(t)=q(t)e^{\int p(t)\, {\rm d}t}$, then $$C(t)=\int e^{\int p(t)\,{\rm d}t}q(t)\, {\rm d}t+C.$$ Hence we get $$x(t)=\left(\int e^{\int p(t)\,{\rm d}t}q(t)\, {\rm d}t+C \right)e^{\int -p(t)\, {\rm d}t}$$ that is evidently the same as what we found using the integrating factor method. Therefore, we arrived also for $$x(t)=e^{t+\sin(t)\cos(t)}\left( \int e^{-t\sin(t)\cos(t)\, {\rm d}t}\sin(t)\, {\rm d}t+C\right).$$
Of course, the "problem" here is that $\int e^{-t-\sin(t)\cos(t)\, {\rm d}t}\sin(t)\, {\rm d}t$ seems doesn' have a closed form using elementary functions. However, that does not mean that you have made a mistake in your approach (notice that $e^{-t-\sin(t)\cos(t)}=\frac{1}{e^{\frac{\sin(2t)}{2}+t}}$). In fact, we know by the Existence and Uniqueness theorem that IVP given by $$\begin{cases} x'(t)+p(t)x(t)=q(t),\\ x(t_{0})=x_{0}\end{cases}$$ has solution and the solution is only for each $t\in \left] a,b\right[$ with $p,q\in \mathcal{C}(]a,b[,\mathbb{R})$ and $t_{0}\in \left]a, b\right[$. So, we can use numerical method to find approximate solutions for the differential equation on intervals $\left]a,b\right[$.
