Second order homogeneous differential equations: why do repeated roots modify the solution set? Consider the following differential equation with constant coefficients:
$$
y'' + 2ky' + k^2y = 0 \, .
$$
The auxiliary equation is
\begin{align}
m^2 + 2km + k^2 &= 0 \\[4pt]
(m+k)^2 &= 0 \\[4pt]
m &= -k \, .
\end{align}
This means that the solutions of the differential equation are $Ae^{-kx}+B\color{red}{x}e^{-kx}$, where $A$ and $B$ are arbitrary constants. The $x$-term highlighted in red is what confuses me. Generally speaking, if the roots of the auxiliary equation are $\alpha$ and $\beta$, then the solutions to the differential equation are $Ae^{\alpha x} + Be^{\beta x}$. However, if $\alpha=\beta$, then the solutions are not $Ae^{\alpha x} + Be^{\alpha x}$—or at least, this solution is incomplete. I can verify that $y=xe^{-kx}$ is a solution of the differential equation by plugging it back in to the equation, but I'm looking for a deeper reason for why this occurs.
 A: $$y'' + 2ky' + k^2y = 0 \, .$$
$$(y' + ky)' + k(y'+ky) = 0 $$
$$((y' + ky)e^{kt})' = 0 $$
Is equivalent to:
$$(ye^{kt})''=0$$
Inetgrate twice and the solution will be obvious.
A: Taking inspiration from Aryadeva's answer, I have found a direct method of solving the differential equation
$$
y'' + by + cy = 0
$$
which takes into account what happens when you have a repeated root. This equation has the auxiliary equation
$$
m^2+bm+c=0 \, .
$$
Say $\alpha$ and $\beta$ are the roots of the auxiliary equation. Then, the equation can be rewritten as
$$
(m-\alpha)(m-\beta)=0
$$
which implies that $b=-(\alpha + \beta)$ and $c=\alpha\beta$. Then, the original equation can be rewritten as
$$
y'' -(\alpha+\beta)y' + \alpha\beta y =0 \, .
$$
It can then be directly shown that
\begin{align}
y&=Ae^{\alpha x}+Be^{\beta x} \quad\text{if $\alpha\neq\beta$} \\[4pt]
y&=(A+Bx)e^{\alpha x} \quad\text{if $\alpha = \beta$} \, .
\end{align}
Here is how:
\begin{align}
y'' -(\alpha+\beta)y' + \alpha\beta y &= 0 \\[6pt]
y'' - \alpha y' - \beta y' + \alpha\beta y &= 0 \\[6pt]
y'' - \alpha y' - \beta (y' - \alpha y) &= 0 \\[6pt]
(y'' - \alpha y')e^{-\beta x} - \beta (y' - \alpha y)e^{-\beta x} &= 0 \\[6pt]
\left[(y' - \alpha y)e^{-\beta x}\right]' &= 0 \\[6pt]
(y' - \alpha y)e^{-\beta x} &= B \\[6pt]
y' - \alpha y &= Be^{\beta x} \\[6pt]
e^{-\alpha x}y' - \alpha e^{-\alpha x}y &= Be^{(\beta - \alpha)x} \\[6pt]
\left[e^{-\alpha x} y \right]' &= Be^{(\beta - \alpha)x}
\end{align}
Suppose that $\alpha \neq \beta$. Then, the following manipulations are justified:
\begin{align}
e^{-\alpha x}y &= \int Be^{(\beta - \alpha)x} \, dx = \frac{Be^{(\beta - \alpha)x}}{\beta - \alpha} + A\\[6pt]
y &= \frac{B}{\beta - \alpha}e^{\beta x} + Ae^{\alpha x} \, .
\end{align}
But then, since $\frac{B}{\beta - \alpha}$ is just some arbitrary constant, we may relabel it as $B$. We are left with
$$
\boxed{
\;\\[4pt]
\quad y=Ae^{\alpha x}+Be^{\beta x} \quad
\\
}
$$
as expected. If $\alpha = \beta$, then the above reasoning is invalid since we end up with division by zero. Instead,
$$
e^{-\alpha x}y = \int Be^{(\beta - \alpha)x} \, dx = Bx + A
$$
and therefore
$$
\boxed{
\;\\[4pt]
\quad y = (A+Bx)e^{\alpha x} \, . \quad
\\
}
$$
A: As the commenters point out, we know that there must be two independent solutions, even without knowing what they are. It is a sensible guess to try something like $xe^{-kx}$. An algorithmic way to find that this is the correct factor is to use variation of parameters.
Indeed, you may find it illuminating to transform the equation by making the substitution $y = e^{-kx}v$ and deriving the equation for $v$.
There are many direct ways of interpreting this change in the solution set. One way is by making small perturbations. Indeed, suppose we had solutions $k_\pm = -k \pm \varepsilon$. Then we get independent solutions $y = Ae^{(-k-\varepsilon)x} + Be^{(-k+\varepsilon)x} = e^{-kx}(Ae^{-\varepsilon x} + Be^{\varepsilon x})$. Then, with some initial data we have $$y = e^{-kx}\bigg(y(0) \cosh(\varepsilon x) + (y'(0) + ky(0)) \frac{\sinh(\varepsilon x)}{\varepsilon}\bigg) \to e^{-kx}\bigg(y(0) + (y'(0)+ky(0))x\bigg).$$
There are other ways. You can rewrite the equation in matrix form:
$$\frac{d}{dx}\pmatrix{y' \\ y} = \pmatrix{-2ky' - k^2 y  \\ y'} = \pmatrix{-2k & -k^2 \\ 1 & 0}\pmatrix{y' \\ y}$$
In the two-root case the matrix is diagonalisable, and the solutions given by the matrix exponential. The matrix above is not diagonalisable, and the $x$ factor arises from its Jordan Normal Form. There are details in this talk if you're interested.
A: Set
$$
z=y\mathrm{e}^{kx}
$$
Then
$$
z''=(y\mathrm{e}^{kx})''=(y'\mathrm{e}^{kx}+ky\mathrm{e}^{kx})'
=y''\mathrm{e}^{-kx}+2ky'\mathrm{e}^{-kx}+k^2y\mathrm{e}^{-kx}=(y''+2ky'+k^2y)\mathrm{e}^{-kx}=0
$$
and hence
$$
z''=0\quad\Longrightarrow\quad z=c_1+c_2x\quad\Longrightarrow\quad y=(c_1+c_2x)\mathrm{e}^{-kx}
$$
