Find the general solution of $\frac{dy}{dx}+y=2\sin(x)$. A particular solution to 
$$\frac{dy}{dx}+y=2\sin(x)$$ 
is $y_p=\sin(x)-\cos(x)$. Using the integrating factor $\rho(x)=e^{x}$, I get a complimentary solution $y_c=\sin(x)-\cos(x)+e^{-x}C$. My goal was to show that $y(x)=y_c+y_p$ is a general solution to $y'+y=2\sin(x)$. So
$$y(x)=y_c+y_p$$
$$y(x)=2\sin(x)-2\cos(x)+e^{-x}C$$
and
$$\frac{d}{dx}(y(x))=2\cos(x)+2\sin(x)-e^{-x}C$$
Adding gives $y'+y=4\sin(x)$. But clearly $4\sin(x)\neq2\sin(x)$. Where did I go wrong?
 A: A differential equation such as $y'+y=f(x)$ is linear (with constant coefficients).
Suppose $y_1$ and $y_2$ are solutions; then, if we consider $y_0=y_1-y_2$, then
$$
y_0'+y_0=y_1'-y_2'+y_1-y_2=f(x)-f(x)=0
$$
so $y_0$ is a solution for $y'+y=0$.
Conversely, if $y_p$ is a solution to $y'+y=f(x)$ and $y_c$ is a solution to $y'+y=0$, then $y_p+y_c$ is a solution to $y'+y=f(x)$.
Hence, the general solution to the equation is of the form
$$
y_p+y_c
$$
where $y_p$ is a particular solution (anyone you are able to determine) and $y_c$ is a solution of the associated homogeneous equation $y'+y=0$ (in your terminology, a complementary solution). Note that this holds for a generic linear differential equation.
Thus the general solution for your equation is
$$
y=\sin x-\cos x+Ce^{-x}
$$

The method with the integrating factor directly gives the general solution, not the complementary one. The equation can be written
$$
e^xy'+e^xy=2e^x\sin x
$$
The left-hand side can be rewritten as $(e^xy)'$, so we get
$$
e^xy=\int 2e^x\sin x\,dx=e^x\sin x-e^x\cos x+C
$$
and therefore the general solution is
$$
y=\sin x-\cos x+Ce^{-x}
$$

Alternatively, we look for a particular solution in the form $y_p=a\sin x+b\cos x$, so we need
$$
a\cos x-b\sin x+a\sin x+b\cos x=2\sin x
$$
which gives $a-b=2$ and $a+b=0$, so $a=1$ and $b=-1$.
The complementary solution is of the form $Ce^{kx}$, where $k$ is the root of $X+1=0$ (the characteristic polynomial), so $k=-1$. Hence $y_c=Ce^{-x}$ and the general solution is
$$
y_p+y_c=\sin x-\cos x+Ce^{-x}
$$
A: $$
y_h'+y_h = 0 \rightarrow Ce^{\lambda x}(\lambda + 1) = 0 \rightarrow \lambda = -1 \rightarrow y_h = Ce^{-x}
$$
$$
y = y_p+y_h = \sin x-\cos x + Ce^{-x}
$$
$$
y'+y = \cos x + \sin x - Ce^{-x}+\sin x-\cos x + Ce^{-x} = 2\sin x
$$
