\documentstyle[12pt]{article}
\begin{document}
\title{Linear First Order Differential Equations}
\maketitle
\section{The variation of constants method}

We start with the homogeneous equation
$$y'+p(t)y=0.$$
To solve this, we simply divide by $y$,
$$y'/y+p(t)=0,$$
and then integrate
$$\ln|y|+\int^t p(s)\,ds=K,$$
where $K$ is an integration constant.
We take the exponential on both sides:
$$|y|\exp(\int^t p(s)\,ds)=e^K.$$
This yields
$$y=\pm e^K\exp(-\int^t p(s)\,ds).$$
We define a new constant $C=\pm e^K$, so we can put the solution in the
form
\begin{equation}
y=C\exp(-\int^t p(s)\,ds).\label{e1}
\end{equation}

Now we look at an inhomogeneous equation
\begin{equation}
y'+p(t)y=g(t).\label{e2}
\end{equation}
The idea of the variation of constants method is to look for a solution in
a form similar to (\ref{e1}). Obviously, something has to change since the
equation has changed. The change is that the constant $C$ is replaced by
a function $C(t)$. So we set
$$y=C(t)\exp(-\int^t p(s)\,ds).$$
We differentiate using the product and chain rules to find
$$y'=C'(t)\exp(-\int^t p(s)\,ds)-C(t)p(t)\exp(-\int^t p(s)\,ds),$$
and
$$y'+p(t)y=C'(t)\exp(-\int^t p(s)\,ds).$$
Thus our differential equation becomes
$$C'(t)\exp(-\int^t p(s)\,ds)=g(t),$$
so that
$$C'(t)=g(t)\exp(\int^t p(s)\,ds).$$
We can then find $C(t)$ by integrating this equation.

The result is evidently the same as what we found using the integrating factor
method, but the ideas leading to the result were different. While for first
order linear equations the integrating factor method and the variation
of constants method are the same, the difference is in how they can be
generalized. The integrating factor method can be generalized to some nonlinear
equations of first order. The variation of constants method, on the other
hand, can be generalized to linear equations of higher order and to linear
systems.

\section{The method of undetermined coefficients}

This method is more limited in scope; it applies only to the special case
of (\ref{e2}), where $p(t)$ is a constant and $g(t)$ has some special form.
The advantage of the method is that it does not require any integrations and
is therefore quick to use. The homogeneous equation
$$y'+\lambda y=0$$
has the solution
$$y_h=Ce^{-\lambda t}.$$
To solve the inhomogeneous equation 
$$y'+\lambda y=g(t),$$
it suffices to find one particular solution $y_p(t)$. If $y_p(t)$ is any
particular solution, then the general solution is
$$y(t)=y_p(t)+Ce^{-\lambda t}.$$

The idea behind the method of undetermined coefficients is to look for
$y_p(t)$ which is of a form like that of $g(t)$. This is possible only for
special functions $g(t)$, but these special cases arise quite frequently in
applications.

We start with the case where $g(t)$ is an exponential:
$$g(t)=Ae^{\alpha t}.$$
We look for $y(t)$ in a similar form
$$y(t)=ae^{\alpha t}.$$
This leads to
$$y'=a\alpha e^{\alpha t},\quad y'+\lambda y=(\alpha+\lambda)ae^{\lambda t}.$$
So the differential equation becomes
$$(\alpha+\lambda)ae^{\alpha t}=Ae^{\alpha t}.$$
We can solve this to find $a=A/(\alpha+\lambda)$. This leads to the particular
solution
$$y_p(t)={A\over \alpha+\lambda}e^{\alpha t},$$
and the general solution
\begin{equation}
y(t)={A\over \alpha+\lambda}e^{\alpha t}+Ce^{-\lambda t}.\label{e3}
\end{equation}

Example: Find the general solution of the equation
$$y'+2y=e^t.$$
The solution of the homogeneous equation is $C\exp(-2t)$, and we look
for a particular solution in the form $y_p=ae^t$. Setting $y=ae^t$ in
the equation, we find
$$ae^t+2ae^t=e^t,$$
leading to $a=1/3$. The general solution is
$$y={1\over 3}e^t+Ce^{-2t}.$$

Why did this work? The idea is simply that if $y$ is an exponential, then so
is $y'$, and so if both $y$ and $g$ are exponentials, then all terms in
the equation are exponentials and we can hope to obtain a solution by setting
coefficients equal to each other. 

There are some other classes of functions for which this works. For instance,
if $y$ is a polynomial of degree $n$, then $y'$ is a polynomial of degree
$n-1$. If $g$ is a polynomial, we can therefore look for polynomial solutions.
Consider
$$y'+2y=t^2.$$
The right hand side is a polynomial of degree 2, so we look for a solution
in the same form $y=at^2+bt+c$. This leads to $y'=2at+b$, and
$$y'+2y=2at^2+(2a+2b)t+b+2c=t^2.$$
To satisfy this, we want to set
$$2a=1,\quad 2a+2b=0,\quad b+2c=0.$$
This leads to $a=1/2$, $b=-1/2$, $c=1/4$.
So a particular solution is
$$y_p={t^2\over 2}-{t\over 2}+{1\over 4}.$$
The general solution is
$$y={t^2\over 2}-{t\over 2}+{1\over 4}+Ce^{-2t}.$$
 
We note that the solution (\ref{e3}) breaks down if $\alpha=-\lambda$, since
it would involve a division by zero. More generally, if the equation reads
$$y'+\lambda y=g(t),$$
and $g(t)=\exp(\alpha t)P_n(t)$, with $P_n(t)$ an $n$th degree polynomial,
then we can find a particular solution $y_p(t)=\exp(\alpha t)Q_n(t)$, where
$Q_n(t)$ is some other $n$th degree polynomial as long as $\alpha\neq -\lambda$.
In the two examples above, we had $\lambda=-2$ and $\alpha=1$, $\alpha=0$,
respectively, so $\alpha\neq -\lambda$. If, on the other hand,
$\alpha=-\lambda$, we have to modify the procedure. The modification is
simply to include an extra factor $t$ in the solution. That is, instead of
setting $y_p=\exp(\alpha t)Q_n(t)$, you set $y_p=t\exp(\alpha t)Q_n(t)$.

{\bf Examples:}

1. 
$$y'+2y=te^{-2t}.$$
Here $\lambda=2$ and $\alpha=-2$, so $\alpha=-\lambda$. The right hand side
is a first degree polynomial times $e^{-2t}$. So we look for a solution of
the form
$$y=te^{-2t}(at+b)=e^{-2t}(at^2+bt).$$
We find
$$y'=e^{-2t}(-2at^2+(2a-2b)t+b),$$
so that
$$y'+2y=e^{-2t}(2at+b)=te^{-2t}.$$
We compare coefficients to find $a=1/2$, $b=0$.
The general solution of the equation is
$$y={1\over 2}t^2e^{-2t}+Ce^{-2t}.$$

2. 
$$y'+2y=te^t.$$
In this case $\lambda=2$ and $\alpha=1$, so $\alpha\neq -\lambda$, and we
do not need the extra factor $t$. So we look for a solution of the form
$$y=e^t(at+b).$$
This leads to
$$y'+2y=e^t(3at+3b+a)=te^t,$$
so we need
$$3a=1,\quad 3b+a=0,$$
leading to $a=1/3$, $b=-1/9$.
The general solution is
$$y=({t\over 3}-{1\over 9})e^t+Ce^{-2t}.$$

3. 
$$y'=t.$$
In this case $\lambda=\alpha=0$, and the right hand side is a first degree
polynomial, so we look for a particular solution of the form $y=t(at+b)=at^2
+bt$. We find
$$y'=2at+b=t,$$
leading to $a=1/2$, $b=0$. The general solution is
$$y={t^2\over 2}+C.$$
\end{document}
