Find the differential equation of $y=e^{-x}+ax+b$ Find the differential equation of $$y=e^{-x}+ax+b$$   where $a,b$ are arbitrary constants.
I differentiated both sides first, and got $$\dfrac{dy}{dx}=-e^{-x}+a.$$  
Making substitution for value of $a$ in the original equation and differentiating again, I got $$x\dfrac{d^2y}{dx^2}=2e^{-x}-xe^{-x}.$$  
So, the differential equation turns out to be $$\dfrac{d^2y}{dx^2}=\dfrac{e^{-x}(2-x)}{x}.$$  
Have I made any mistake here? My teacher struck the whole thing out and gave me a $0$ here. Please help.
 A: Perhaps you saw this in the context of linear second order differential equations with constant coefficients? Then in the form of the solution, you recognize what should be the solution of the homogeneous part (in blue) and a particular solution (in red):
$$y=\color{red}{e^{-x}}+\color{blue}{ax+b}$$
Now for the homogeneous part, you need a double zero root to the characteristic equation so this is clearly the solution to:
$$y''=0$$
To get $e^{-x}$ as a particular solution, the inhomogeneous part of the differential equation (the "right-hand side") will be of the form $Ae^{-x}$ and you can verify (easily) that $A=1$ does the trick, so:
$$y''=e^{-x} \tag{$\square$}$$
has $y=\color{red}{e^{-x}}+\color{blue}{ax+b}$ as general solution.

Addition after comment.

$$\dfrac{dy}{dx}=-e^{-x}+a. \tag{$*$}$$
Making substitution for value of $a$ in the original equation and differentiating again, I got $$x\dfrac{d^2y}{dx^2}=2e^{-x}-xe^{-x}.$$

If you substituted $(*)$ in the original solution, where did the $b$ go? Why not differentiate $(*)$ again, this immediately yields $(\square).$
