Solving non homogeneous differential equation I have the following equation:
$$\frac{dx}{dt}+x=4\sin(t)$$
For solving, I find the homogenous part as:
$$f(h)=C*e^{-t}$$
Then finding $f(a)$ and $df(a)$:
$$f(a)=4A\sin(t)+4B\cos(t)$$
$$df(a)=4A\cos(t)-4B\sin(t)$$
Substituting in orginal equation:
$$4A\cos(t)-4B\sin(t)+4A\sin(t)+4B\cos(t)=4\sin(t)$$
I have to find numerical values of $A$ and $B$ but I absoloutly have no idea how can I solve this, I am also not sure if the steps I did are correct or not. Would somone please help with this equation?
The final answer should be substituted in:
$$x=f(h)+f(a)$$
 A: Another approach would be to consider the given equation as one of the form
$$
\frac{dx}{dt}+Px=Q
$$
where $P$ and $Q$ are functions of $t$. Such equation can be solved by multiplying both sides by the integrating factor $e^{\int P\,dt}$.
Applying this to your equation, we get
$$
\begin{align}
e^{t}\frac{dx}{dt}+e^t x=e^t 4 \sin{t}\\
\frac{d}{dt}\left(xe^t\right)=4\,e^t \sin{t}\\
xe^t=4\int e^t  \sin{t}\ dx\\
\end{align}
$$
Solving the above by integration by parts we get
$$
\begin{align}
xe^t&=\frac{4e^t(\sin t -\cos t)}{2} + c\\
x&=2\sin t -2\cos t+ce^{-t}
\end{align}
$$
A: multiples of $\cos(t)$ can't add to make $\sin(t)$, and vice versa. So this can be split into two equations:
$$4A\cos(t)+4B\cos(t)=0$$
$$4A\sin(t)-4B\sin(t)=4\sin(t)$$
simplifying we get
$$A+B=0$$
$$A-B=1$$
and so 
$$A=\frac{1}{2}, B=-\frac{1}{2}$$
So your final solution is $$x=f(h)+f(a)=Ce^{-t}+2\sin(t)-2\cos(t)$$
A: At the stage
$$4A\cos(t)-4B\sin(t)+4A\sin(t)+4B\cos(t)=4\sin(t)$$
you are done. Collecting common factors you will get
$$4(A+B)\cos(t)+4(A-B-1)\sin(t)=0$$
but this must be independent and so you have a system of equations
$$A-B=1$$
$$A+B=0$$
giving $A=-B=\frac{1}{2}$.
