First Order Linear Differential Equations: Solve dy/dx = x+ 2y $\frac{dy}{dx} = x + 2y$
My attempt using the method described in the textbook "Thomas Calculus":
$$\frac{dy}{dx} - 2y = x$$
$$P(x)= -2$$
$$Q(x)= x$$
Integral of $-2\, dx = -2x$.
Then take the exponential function ($e$) raised to $-2x$ to get $v(x)$.
Then, by the textbook method, the equation become the reciprocal of $v(x)$ times the integral of $[(v(x)) x]$
At which point I get $\frac{1}{e^{-2x}} (x e^{-2x})$
which equals $x$... however I don't think this is correct. Please Help! 
 A: The $v(x)$ that you mention is known as an integrating factor.  Multiplying both sides of the equation by it, in this case $e^{-2x}$ results in
$$e^{-2x}y'-2e^{-2x}y=(e^{-2x}y)'=xe^{-2x}$$
So to solve from here, integrate, then multiply both sides of the equation by $e^{2x}$, yielding, as you have stated
$$\frac1{v(x)}\int xv(x)dx=e^{2x}\int xe^{-2x}$$
However, this does not result in what you have.  You either forgot to integrate (you did mention the integral of $xv(x)$) or you performed the integration incorrectly.  Use integration by parts and you should have your answer.
A: Now you should integrate the second term of your last expression:
$y=\frac{1}{e^{-2x}} \int (x e^{-2x}) \ dx=e^{2x} \int (x e^{-2x}) \ dx$
partial integration:
$u=x \Rightarrow u'=1$
$v'=e^{-2x} \Rightarrow v=-\frac{1}{2}e^{-2x}$
$\int (x e^{-2x}) \ dx=u\cdot v-\int u'\cdot v=-\frac{1}{2}e^{-2x}\cdot x-\int -\frac{1}{2}e^{-2x} \ dx$
I think you can go on from here. Don´t forget the constant of integration.
A: When a differential eq is in the form $\frac{dy}{dx} = Ay + Bx + C$, I always solve it this way:
Assume $y$ is of the form mx + b where $m \text{ and } b$ are arbitrary constants. Then, following your example:


*

*Re-write your equation as $m = 2(mx + b) + x$ (because y = mx + b and m is the slope of the line.)

*Rearrange it so it becomes $x(\text{function of m}) + (\text{constant})b.$ In your case, $0x + m = x(2m + 1) + 2b$.

*This is like equating real and imaginary parts. Split the equation into parts so it becomes $\color{orange}{0x} + \color{lime}{m} = \color{orange}{x(2m + 1)} + \color{lime}{2b}$.
I did this so that we can equate coefficients of x and solve for m, then equate the green parts and solve for b. In this case, $$\color{orange}{2m+1 = 0}$$ $$\text{and}$$ $$\color{lime}{m = 2b.}$$


The solution is then, $y = -\frac{1}{2}x - \frac{1}{4}.$
