\docname{sess5.1}
\doctitle{Linear First Order ODE's}

\mylhead
\myrhead

\title{\doctitle}
\maketitle

\section{First Order Linear Equations}

Definition: A {\bf linear ODE} is one that can be put in the form:
\[r(t)\overdot x + p(t)x = q(t), \qquad
x = x(t).\]
Here $r(t)$ and $p(t)$ are the {\em coefficients} of the ODE.
The left hand side represents the {\em system} and the right hand side
arises from an {\em input signal}. A solution $x(t)$ is a {\em system response}
or {\em output signal}.

We can always divide through by $r(t)$ to get an equation of the
standard form:
\begin{equation}\label{eq5.1.1}
\overdot x + p(t)x = q(t), \qquad x = x(t).
\end{equation}

\section{Homogeneous equations}

The equation is {\em homogeneous} if $q$ is the {\em null signal} $q(t) = 0$.
This corresponds to letting the system evolve in isolation:
\begin{itemize}
\item In the bank example, no deposits and no withdrawals.
\item In the RC example, the power source is not providing any voltage
  increase.
\end{itemize}

The homogeneous linear equation:
\begin{equation}\label{eq5.1.2}
\overdot x + p(t) x = 0
\end{equation}
is separable. We can find the solution as follows:\\
\begin{itemize}
\item Separate: $\qquad \displaystyle{\frac{dx}{x} = - p(t) dt}$.\\
\item Integrate: $\qquad \ln|x|=-\int p(t) dt + c$.\\
\item Exponentiate:  $\qquad |x| = e^c e^{-\int p(t) dt}$.\\
\item Eliminate the absolute value and reintroduce the lost solution:\\
$x = C e^{- \int p(t) dt}.$
\end{itemize}

\example $\overdot x+2tx=0$

\begin{itemize}
\item Separate: $\qquad \displaystyle{\frac{dx}{x}=-2tdt}$.\\
\item Integrate: $\qquad \ln|x|=-\int 2tdt=-t^2+c$.\\
\item Exponentiate: $\qquad |x|=e^ce^{-t^2}$.\\
\item Eliminate the absolute value and reintroduce the lost
  solution:\\
 $x=Ce^{-t^2}$.
\end{itemize}

In the example, we chose a particular anti-derivative of $-2t$, namely $-t^2$.
That is what I have in mind to do in general; the constant of
integration is taken care of by the constant $C$.

The {\bf general solution} to (\ref{eq5.1.2}) has the form $C x_h$,
where $x_h$ is \textit{any} nonzero solution:
\[x_h = e^{- \int p(t) dt}, \qquad x=C x_h.\] Below, we see that the
inhomogeneous equation (\ref{eq5.1.1}) can be solved by an algebraic trick
that produces a sequence of two integrations.

\section{Inhomogeneous DE's via Integrating Factors}

This method is based on the product rule for integration:
\[\frac{d}{dt}(ux)'=u\overdot x+\overdot u x.\]
Start with equation (\ref{eq5.1.1}):
\[\overdot x+p(t)x=q(t).\]
In order to apply the product rule, we want the sum on the left hand
side of the equation to have the form $u\overdot x+\overdot u x$ for
some function $u(t)$.  At present that's not true unless $p(t) = t$.
We adjust the equation by multiplying both sides by some function
$u(t)$, whose value we will determine later:
\begin{equation}\label{eq5.1.3}
u\overdot x+upx=uq.
\end{equation}
There may be (and will be) many functions $u$ for which the left
hand side of this equation is $\frac{d}{dt}(ux)$; we only need to find
one of them.
\begin{align*}
\frac{d}{dt}(ux) = u\overdot x+\overdot ux &=u\overdot x+upx\\
\overdot u&=up.
\end{align*}
This is separable:
\[\frac{du}{u}=p(t)\, dt\]
and so:
$$
\ln |u|  =\int p(t)\, dt\\$$
$$u=e^{\int p\, dt}.
$$
Any choice of antiderivative for $p(t)$ will do - we are just looking
for one $u$ that works and don't need the general solution.

Now replace the left-hand side of
(\ref{eq5.1.3}) by $\frac{d}{dt}(ux)$ and solve for $x$:
\begin{align*}
u \overdot x + upx &= uq\\
\frac{d}{dt}(ux)&=uq\\
u(t)x(t)&=\int u(t)q(t)dt+c\\
x(t)&=\frac{1}{u(t)}\left(\int u(t)q(t)dt+c\right)
\end{align*}
We have the general solution:
\begin{equation}\label{eqgensol}
x(t)=\frac{1}{u(t)}\int u(t)q(t) dt +
\frac{c}{u(t)}.
\end{equation}  The function $u$ is called an {\bf integrating
  factor}.

\example Heat Diffusion

Let's carry out the method in an explicit example.  

About this time of year I start to think about summer. I put my root beer
in a cooler, but it still gets warm. Let's model its temperature by an ODE:
$$x(t) = \text{ root beer temperature at time }t.$$

The greater the temperature difference between inside and outside, the
faster $x(t)$ changes.  The simplest (linear) model of this is:
$$
\overdot x(t) = k ( T_{\text{ext}}(t) - x(t) ),
$$
where $T_{ext}(t)$ is the external temperature.  This makes sense: when the outside temperature
$T_{\text{ext}}$ is greater than the inside temperature $x(t)$, then
$\overdot x(t) > 0$ (assuming $k > 0$).  

\hbcom{If time permits, add a table showing

$$T_ext > x ==> x' > 0$$
$$T_ext < x ==? x' < 0$$

and then drawing a graph of $x'$ against $x - T_ext$ and deciding that as
long
as the difference is small it's well approximated by  $k(T_ext - x)$.}

We get the linear
equation:
\begin{equation}\label{eq5.1.4}
\overdot x - k x = k T_{\text{ext}}.
\end{equation}
This is {\bf Newton's law of cooling}; $k$ could depend upon $t$ and we would
still have a linear equation, but let's suppose that we are not watching
the process for so long that the insulation of the cooler starts to break
down!{\footnote{On the other hand, if you plot
$\overdot x$ against $x$ over a larger range of temperatures $x$, you'll discover that the graph isn't a straight line forever:
the cooler melts or the crystal lattice rearranges and the the cooling
properties change. If you include these effects then the equation is
no
longer linear.}}

Systems and signals analysis:
\begin{itemize}
\item The system is the cooler.
\item The input signal is the external temperature $T_{\text{ext}}(t)$.
\item The output signal or system response is $x(t)$, the temperature in the cooler.
\end{itemize}
Note that the right-hand side of equation~(\ref{eq5.1.4}) is $k$ times
the input signal, not the input signal itself.
What constitutes the input and output signals is a matter of the
interpretation of the equation, not of the equation
itself.

To be specific, let $x(0) = 32$ degrees Farenheit, $k=\frac 13$ and
$T_{\text{ext}}=60+6t$, where $t$ denotes hours after 10AM. (The
outside temperature is rising linearly.)
We get the following differential equation and initial value:
\begin{equation}\label{eq5.1.5}
\overdot x+\frac 13 x = 20+2t, \qquad x(0)=32.
\end{equation}

\ans We could just plug
in to (\ref{eqgensol}), but I never do.  Instead I apply the method of
integrating factors to the differential equation I'm given.

Multiply both sides by $u$: 
\begin{equation}\label{eqcooler}
u\overdot x+\frac 13 ux = u(20+2t).
\end{equation}
Next, set the left hand side equal to $\frac{d}{dt}(ux)$ and find the
integrating factor $u$: 
\begin{align*}
u\overdot x+\frac 13 ux&=u\overdot x+\overdot ux\\
\overdot u&=\frac 13 u\\
u(t)&=e^{\frac 13 t}.
\end{align*}
Since any nonzero solution will do, we may choose to let $C=1$ in the general
solution $u(t)=Ce^{\frac 13 t}$.  \hbcom{Deleted sentence about
  exponential growth equation.}

Now replace the right hand side of (\ref{eqcooler}) by $\frac{d}{dt}(ux)$ and
solve for $x$.  We chose $u$ so that $\frac{d}{dt}(ux) = u \overdot x + \frac{1}{3}ux$, so:
\begin{align*}
u(\overdot x + \frac{1}{3} x) &= u(20 + 20t)\\
\frac{d}{dt}(e^{\frac 13 t} x)&=e^{\frac 13 t}(20+2t)\\
e^{\frac 13 t}x&=\int e^{\frac 13 t}(20+2t)\,dt\\
&=60e^{\frac 13 t}+6te^{\frac 13 t}-18e^{\frac 13 t}+c \qquad \text{(integration by parts)}\\
x(t)&=60+6t-18+ce^{-\frac 13}t\\
&=42+6t+ce^{-\frac 13 t}.
\end{align*}
This is the general solution to (\ref{eq5.1.5}).  If we let $c=0$ we
get a particular solution which is a polynomial (we'll see later that
this is quite easy to determine by other methods).  All that remains
is to find the value of $c$ that describes the particular behavior of
my cooler.

We plug in $t=0$ and use the initial condition to find $c$: 
$$x(0)=42+c \quad \Rightarrow \quad c=-10.$$
The equation describing the temperature inside my cooler is:
\[x(t)=42+6t-10e^{-\frac 13 t}.\]



\section{The Integrating Factor and $x_h$}

Comparing the formula for the integrating factor $u=e^{\int p(t)dt}$
to the solution $x_h=e^{-\int p(t)dt}$ to the homogenous equation
(\ref{eq5.1.2}), we get the following expression for $x_h$: $$x_h(t) =
\frac{1}{u(t)}.$$
The significance of $x_h$ is (partially) described in the next
section.
\hbcom{Double check previous sentence.}


\section{General $=$ Particular $+$ Homogeneous}

\hbcom{I guessed which equation to refer to here.}

Note the structure of the general solution (\ref{eqgensol}):
$$x = x_p + c u^{-1},$$
where $x_p$ is a solution, {\em any solution} of
(\ref{eq5.1.1}). It's called a {\bf particular solution}, but this is
a very poor name because there is nothing particular about it.  In
this example we chose one with a pretty simple formula: $$x_p = 42 +
6t.$$ Since $x_h= \frac{1}{u(t)}$, we can rewrite the general solution
as $x=x_p+cx_h$.

Very often $x_h$ approaches zero with time, as happens here. It is then
called a {\bf transient}. All solutions come to look more and more alike as
time goes on. This is a funnel!

