If y(x) is a solution to a differential equation, why is xy(x) also a solution? I'm taking an intro to ODE's course and we've been taught that in situations when we have two linearly dependent solutions, for example $y_1=e^x$ and $y_2=e^x$, we can multiply this solution by x to get a linearly independent solution. So in this case we would get $y(x)=c_1 e^x +c_2 xe^x$. Are there constraints for when this is true? Can we always multiple a solution by the independent variable to get another linearly independent solution? Why wouldn't the above solution instead be $y(x)=c_1 e^x +c_2 xe^x +c_3 x^2e^x$?
 A: No, this does not always work; it's a special thing in constant coefficient equations with repeated roots. The fact that multiplying by $x$ yields a function linearly independent from the one you started with is not special, but the fact that multiplying by $x$ yields another solution at all is special.
One way to see where it comes from is to solve the equation by operator factorization instead of guess-and-check. So if you have a double root of $\lambda$, you can write that as $(D-\lambda)(D-\lambda)y=0$. This suggests substituting $z=y'-\lambda y$, which gives $z'-\lambda z=0$. You can solve that by integrating factors (as you studied earlier in your course). Doing that you get $z=z_0 e^{\lambda x}$.
So now $y'-\lambda y=z=z_0 e^{\lambda x}$, so solving that by integrating factors looks like
$$\int_0^x \frac{d}{dx} \left ( e^{-\lambda t} y(t) \right ) dt = \int_0^x z_0 dt \\
e^{-\lambda x} y - y_0 = x z_0 \\
y = e^{\lambda x}(y_0+xz_0).
$$
You see that this factor of $x$ comes out because the integrating factor exactly cancels out the exponential.
You can do the same thing when you're solving for particular solutions when the right side (or a term in it) is of the form $x^k e^{\lambda x}$.
There is a deeper explanation using linear algebra. Here, these formulas fall out of some Taylor series that appear when you take the matrix exponential $e^{Jx}$, where $J$ is a special kind of matrix called a Jordan block. But if you haven't studied linear algebra already then I would not worry about this for the moment.
A: This occurs when you try to solve a linear ODE with constant coefficients, namely $y' = A y$ (where $A$ is a matrix). In the specific case that you have $y_1 = e^x$ and $y_2=e^x$ as the two linearly dependent "defective" solutions, then $y(x) = c_1 e^x+c_2xe^x$ is the form of the general solution. There is no $x^2 e^x$ term. (Note: "defective" is an important requirement here. It means that the corresponding eigenvalue of the matrix $A$ has no two linearly independent eigenvectors.)
If you have $y_1 = e^x$, $y_2=e^x$ and $y_3 = e^x$ as three linearly dependent solutions and if the corresponding eigenvalue of $A$ has defectiveness $2$, then you have $y(x) = c_1 e^x+c_2xe^x + c_3x^2e^x$ as the general form of the solution.
The deeper reasoning you are looking for is related to concepts from linear algebra: namely the Jordan form of a matrix, Jordan chains and defective eigenvalues. Assuming that you understand these concepts, you can find how to construct the general solution of $y' = A y$ explained here.
