# How to solve: $y'+\int y \mathrm dx = 2y$?

The question is to solve for $y$: $$\frac{\mathrm dy}{\mathrm dx} + \int y\,\mathrm dx = 2y$$ How do I solve this? I differentiated the equation to get $y'' + y = 2y'$, but further solving proved hopeless. Also, by observation $e^x$ is a solution, but the answer he told me is $y=xe^x$, which is also a valid solution! I can't even see how they both can be a part of the same family!

So how do I solve this equation? Since I only know how to solve 1st order differential equations, this is even harder for me.

Thank you.

Your differentiated ODE is a second order linear differential equation with constant coefficients: $$\frac{d^2 y}{dx^2}-2\frac{dy}{dx}+y=0$$ To solve these types, we use the ansatz $y=e^{\lambda x}$ (Substitute it into the ODE) and solve the quadratic for $\lambda$. That quadratic is called the characteristic equation, also known as the auxiliary equation.
Once you solve for $\lambda$, use the appropriate solution for each case:
Case 1: Real, distinct roots (i.e. $\lambda_1 \neq \lambda_2$ where $\lambda_{1,2} \in \mathbb{R}$): $$y(x)=c_1 e^{\lambda_1 x}+c_2 e^{\lambda_2 x}$$
Case 2: Complex roots (i.e. $\lambda_{1,2}=a\pm bi$ where $a,b\in \mathbb{R}$): $$y(x)=c_1 e^{ax}\cos(bx)+c_2 e^{ax} \sin(bx)$$ This comes from the fact that $e^{i\theta}=\cos{\theta}+i\sin{\theta}$. If you are interested in the derivation, click on the link above.
Case 3: Real, repeated roots (i.e. $\lambda_1=\lambda_2=\lambda$ where $\lambda \in \mathbb{R}$): $$y(x)=c_1 e^{\lambda x} +c_2 x e^{\lambda x}$$
The auxiliary equation is $$r^2-2r+1=(r-1)^2=0$$ which has two equal roots $r_1=r_2=1$. The general solution is therefore of form $$y=C_1e^{x}+C_2xe^x$$