using linearity to solve ode Solve the following diﬀerential equation for x(t)
\begin{equation}
\frac{dx}{dt}+ax= b\sin(kt) 
\\
\end{equation}
subject to the initial condition $x(0) = 0$.
you may use   
\begin{equation}
e^{ikt} = \cos(kt) + i \sin(kt)
\end{equation}
my question is how linearity used in order for the solution to only contain the real part? and why are we allowed to substitute 
\begin{equation} 
e^{ikt} 
\end{equation}
for $b\sin(kt)$ in order to solve? 
 A: I would just multiply everything through by $e^{at}$ to obtain
$$e^{at}\frac{dx}{dt}+ae^{at}x=be^{at}\sin(kt),$$
and then recognize the LHS as a total derivative (product rule):
$$\frac{d}{dt}(xe^{at})=be^{at}\sin(kt).$$
Integrate both sides to obtain
$$xe^{at}=\frac{b e^{at}[a \sin(kt)-k\cos(kt)]}{a^{2}+k^{2}}+C,$$
and finally
$$x=\frac{b[a \sin(kt)-k\cos(kt)]}{a^{2}+k^{2}}+Ce^{-at}.$$
Plugging in your initial condition will determine $C$.
A: Using $e^{ikt} = \cos(kt) + i \sin(kt)$, what if we use the substitution $e^{ikt}$ and then make use of linearity to only take the part we need, namely the imaginary part of the solution.
Note, this problem is easy to solve using the typical methods (homogeneous and particular with undetermined coefficients), but if I read your question correctly, it is asking for you to use the linearity approach in order to understand how that method can be used. 
Update
Here is the process for using the approach that is being asked.
$$\tag 1 \dfrac{dx}{dt} + ax = b \sin kt$$
with initial condition $x(0) = 0$.
The problem asks us to use linearity by making use of $e^{ikt} = \cos kt + i \sin kt$.
This allows us to solve the DEQ using the complex exponential and at the end taking the imaginary part of the solution because this is a linear combination and we only need the imaginary part.
So, we can rewrite $(1)$ as:
$$\tag 2 \dfrac{dx}{dt} +ax = b e^{ikt}$$
To solve $(2)$, we can make use of an integrating factor, as:
$$\displaystyle \dfrac{d}{dt}(e^{at}x) = be^{(a+ ik)t}$$
Integrating from $0 ~\text{to}~ t$, yields: $e^{at}x = b\dfrac{1}{a + ik}\left(e^{(a+ik)t} - 1 \right)$
So, 
$$\displaystyle x(t) = b \dfrac{1}{a+ik}\left(e^{ikt}-e^{-at} \right)$$
So, because of the linear combination, we need only take the imaginary part of this result and end up with:
$$\displaystyle x(t) = \dfrac{b \left(ke^{-at} + a \sin kt -k \cos kt \right)}{a^2 + k^2}$$
A: The solution to the homogeneous equation can be found from $\frac{dx}{dt} + ax = 0$ (exponential). A particular solution to the inhomogeneous equation should be sought in the form of $Ae^{ikt}+B$, then you can find A by requiring that coefficients by $cos$ terms be $0$, and those by the $sin$ part equate the right-hand side (1). Furthermore, since $x(0) = 0$, no $cos$ terms can be present, and you have two conditions for $A$ and $B$. Add the general and particular solutions together to get the answer. Good luck!
