Why is it correct to assume $f = e^{\lambda x}$ in differential equation? I was solving the following differential equation:
$$f'' + f = 0$$
And, as I learned in class, I assumed that $f = e^{\lambda x}$ and then found the roots of the polynomial and found the solution. But then the following came to my mind:
Why is it correct to assume that $f = e^{\lambda x}$? How do we know that by doing this we are indeed finding all the solutions of the equation and we aren't only finding the solutions that take that form? Because doing this looks like a guessing game, we try to guess the solution and then find it by correcting and fixing the values of $\lambda$.
 A: $$f'' + f = 0$$
There are many ways to solve this differential equation. Here is one of them:
$$f''\cos x +f \cos x=0$$
$$f''\cos x \color{red}{ -f' \sin x +f'\sin x}+f \cos x=0$$
$$(f'\cos x)' +(f \sin x)'=0$$
After integration we get:
$$f'\cos x +f \sin x=C_1$$
That you can rewrite as:
$$\left ( \dfrac {f}{ \cos x}\right)'=\dfrac {C_1}{\cos^2 x}$$
Integrate and you are done.
$$ \dfrac {f}{ \cos x}= {C_1}{\tan x}+C_2$$
Finally:
$$ {f}(x)= {C_1}{\sin x}+C_2 \cos x$$
A: A guess at what a solution might be does not have lead to all possible solutions.  For example, consider $y'' = 0$.  If you guess that $y(x) = e^{\lambda x}$ then $y''(x) = \lambda^2 e^{\lambda x}$, so $y'' = 0$ only when $\lambda = 0$, which means $e^{\lambda x}$ fits the equation only when $\lambda = 0$.  That leads us to the constant solution $y(x) = 1$, whose span is constant functions.  This completely misses the solutions $y(x) = ax$ for different constants $a$.
Similarly, if you guess a solution to $y'' + 2y' + y = 0$ has the form $y(x) = e^{\lambda x}$ then $y'' + 2y' + y = (\lambda^2 + 2\lambda + 1)e^{\lambda x}$ so to satisfy the ODE is equivalent to $\lambda^2 + 2\lambda + 1 = 0$, and thus $(\lambda + 1)^2 = 0$.  Therefore $\lambda = -1$, and we are led to the solution $e^{-x}$.  Its constant multiples gives us solutions $ce^{-x}$, but this is missing the solution $xe^{-x}$.
What helps you know you have genuinely found all solutions to a linear differential equation is knowing in advance the dimension of the solution space. (If the differential equation is not linear, then the solution space is not closed under linear combinations so things become much more complicated.)  It can be proved that an $n$th order constant coefficient linear ODE has an $n$-dimensional solution space, so as soon as you find $n$ linearly independent solutions, their linear combinations give you all solutions. As I showed above, guessing at formulas for solutions does not have to lead you to a full set of linearly independent solutions.
A: Let’s start with the first degree linear differential equation and see why the homogenous solution is exponential function.
$$
\begin{align}
0&=\frac{d}{dx}y+\lambda y\\
\\
&=e^{\lambda x}\left(\frac{d}{dx}y+\lambda y\right)\\
\\
&=e^{\lambda x}\frac{d}{dx}y+\lambda e^{\lambda x}y\\
\\
&=\frac{d}{dx}\left(e^{\lambda x}y\right)
\end{align}
$$
We see that the differentiation of $e^{\lambda x}y$ yields $0$ i.e. $e^{\lambda x}y=C$ or equivalently $y=Ce^{-\lambda x}$. Therefore, this is not a guessing game. However, they don’t teach students this and only teach students to immediately assume exponential function.
Now let’s solve your question. Recall that $\frac{d}{dx}()$ is a linear operator.
$$
\begin{align}
0&=\frac{d^{2}}{dx^{2}}y+y\\
\\
&=\left(\frac{d^{2}}{dx^{2}}()+()\right)y\\
\\
&=\left(\frac{d}{dx}()+i()\right)\left(\frac{d}{dx}y-iy\right)\\
\\
\end{align}
$$
Now we define $z=\frac{d}{dx}y-iy$ to obtain a first degree differential equation
$$
\begin{align}
0&=\frac{d}{dx}z+iz\\
\\
&=e^{ix}\frac{d}{dx}z+ie^{ix}z\\
\\
&=\frac{d}{dx}\left(e^{ix}z\right)\\
\\
\\
z&=Ce^{-ix}
\end{align}
$$
Now we substitute back to definition of $z$
$$
\begin{align}
Ce^{-ix}&=\frac{d}{dx}y-iy
\\
\\
Ce^{-i2x}&=e^{-ix}\frac{d}{dx}y-ie^{-ix}y\\
\\
&=\frac{d}{dx}\left(e^{-ix}y\right)
\end{align}
$$
Now integrate the last row and substitute $D_{1}=\frac{-C}{2i}$ to obtain
$$
\begin{align}
D_{1}e^{-i2x}+D_{2}&=e^{-ix}y\\
\\
\\
D_{1}e^{-ix}+D_{2}e^{ix}&=y
\end{align}
$$
There you go. Now if you are interested, try to solve $y’’+2y’+y=0$ this way and see if you understand why the solution is $y=D_{1}e^{-x}+D_{2}xe^{-x}$
A: We can't take $~y=e^{\lambda x}~$ as a trial solution to any second order differential equation, but only for the homogenius linear ones with constant coefficients. In fact you should take $~y=e^{\lambda x}~$ as a trial solution for any homogeneous linear ordinary differential equation with constant coefficients.
One possible reason behind this can be explained as follows: The fundamental theorem of algebra says that any $n^{th}$ degree polynomial has exactly $n$ roots (including multilicity). When you assume $~e^{\lambda x}~$ as a trial solution to one of these equations what happens? The equation is of the form: $$a_0y+a_1y'+a_2y''+\cdots+a_ny^{(n)}=0~.$$ Assuming $~y=e^{\lambda x}~$ as the trial solution we have: $$a_0e^{\lambda x}+\lambda a_1e^{\lambda x}+\lambda^2a_2e^{\lambda x}+\cdots+\lambda^na_ne^{\lambda x}=0~.$$ Canceling $~e^{\lambda x}~$ gives: $$a_0+\lambda a_1+\lambda^2a_2+\cdots+\lambda^n a_n=0~.$$ Which is an $n^{th}$ degree polynomial. Therefore we are guaranteed $n$ solutions to this polynomial, and we know that an $n^{th}$ degree linear differential equation has $n$ linearly independent solutions. So, as long as all the roots are distinct, we have solved the problem since $e^{\lambda x}$ and $e^{mx}$ are linearly independent when $~m≠\lambda~$. Otherwise we need to try other solutions as well. The other solutions that work in this case are of the form $~x^α e^{\lambda x}~.$
Note: For non homogeneous linear differential equation obviously $~e^{\lambda x}~$ will not work. In this case we have to choose $~y=x^m~$ which comes from the motivation that a $n$ times differentiable function can be represented as linear combination of power of $~x^m~.$
