\section{Classification of Differential Equations}
\label{sec:ch01_classification}

A \textbf{differential equation} (DE) is a relation between an unknown function and its derivatives. Differential equations are the language of dynamical systems, appearing in physics, engineering, biology, economics, and throughout the applied sciences.

\subsection{Order and Degree}

\begin{definition}[Order]
  The \textbf{order} of a differential equation is the order of the highest derivative appearing in the equation.
\end{definition}

\begin{definition}[Degree]
  The \textbf{degree} of a differential equation is the power of the highest-order derivative, provided the equation is a polynomial in its derivatives.
\end{definition}

\begin{workedexample}
  \textbf{Determine the order and degree of the following equations:}

  \begin{enumerate}
    \item $\displaystyle \frac{\diff^3 y}{\diff x^3} + 2\frac{\diff y}{\diff x} = x$

    The highest derivative is $y'''$, so this is a \textbf{third-order} equation. The highest derivative appears to the first power, so the \textbf{degree is 1}.

    \item $\displaystyle \left(\frac{\diff^2 y}{\diff x^2}\right)^{\!2} + \frac{\diff y}{\diff x} = 0$

    The highest derivative is $y''$, so this is \textbf{second-order}. The highest derivative is squared, so the \textbf{degree is 2}.

    \item $\displaystyle \frac{\diff y}{\diff x} = e^{y} + \sin x$

    Highest derivative is $y'$, so \textbf{first-order}. It appears to the first power, so \textbf{degree 1}.
  \end{enumerate}
\end{workedexample}

\subsection{Linearity}

\begin{definition}[Linearity]
  An $n$-th order differential equation is \textbf{linear} if the unknown function $y$ and all of its derivatives appear to the first power and are not multiplied together. A linear $n$-th order DE has the general form
  \[
    a_n(x)\,y^{(n)} + a_{n-1}(x)\,y^{(n-1)} + \cdots + a_1(x)\,y' + a_0(x)\,y = g(x),
  \]
  where $a_0, a_1, \dots, a_n$ and $g$ are functions of $x$ only.
\end{definition}

If any term violates these conditions, the equation is \textbf{nonlinear}.

\begin{workedexample}
  \textbf{Classify as linear or nonlinear:}

  \begin{enumerate}
    \item $y'' + 3y' + 2y = \cos x$

    All derivatives appear to first power; coefficients depend only on $x$. \textbf{Linear.}

    \item $y'' + y\,y' + y = 0$

    The term $y\,y'$ multiplies $y$ by its derivative. \textbf{Nonlinear.}

    \item $\sin(y) + y' = x$

    The function $y$ appears inside a transcendental function. \textbf{Nonlinear.}
  \end{enumerate}
\end{workedexample}

\subsection{Homogeneity}

\begin{definition}[Homogeneity (linear DEs)]
  A linear differential equation is \textbf{homogeneous} if $g(x) = 0$; i.e., every term contains $y$ or a derivative of $y$. It is \textbf{non-homogeneous} (or inhomogeneous) if $g(x) \neq 0$.
\end{definition}

\begin{workedexample}
  \begin{enumerate}
    \item $y'' - 4y = 0$ \quad $\longrightarrow$ \textbf{Homogeneous linear, second-order.}
    \item $y'' - 4y = e^{2x}$ \quad $\longrightarrow$ \textbf{Non-homogeneous linear, second-order.}
    \item $y' + y^2 = 0$ \quad $\longrightarrow$ \textbf{Nonlinear} (not classified as homogeneous/heterogeneous in the linear sense).
  \end{enumerate}
\end{workedexample}

\subsection{Classification Summary}

\begin{keyresult}
  \textbf{ODE Classification Checklist:}
  \begin{enumerate}
    \item \textbf{Order:} What is the highest derivative? (e.g., $y^{(3)}$ $\Rightarrow$ third order)
    \item \textbf{Degree:} What power is the highest derivative raised to?
    \item \textbf{Linearity:} Does $y$ and every derivative appear only to the first power, never multiplied together?
    \item \textbf{Homogeneity (linear only):} Is $g(x) = 0$? If yes, homogeneous.
  \end{enumerate}
\end{keyresult}

\begin{table}[htbp]
  \centering
  \caption{Classification of example differential equations}
  \label{tab:ch01_classification_table}
  \begin{tabular}{@{} l l c c c @{}}
    \toprule
    \textbf{Equation} & \textbf{Order} & \textbf{Degree} & \textbf{Linear?} & \textbf{Homogeneous?} \\
    \midrule
    $y' + 2y = e^x$ & 1 & 1 & Yes & No \\
    $y'' - 3y' + 2y = 0$ & 2 & 1 & Yes & Yes \\
    $(y'')^2 + y' = 0$ & 2 & 2 & No & --- \\
    $y' = xy + y^2$ & 1 & 1 & No & --- \\
    $y^{(4)} + y'' = 0$ & 4 & 1 & Yes & Yes \\
    \bottomrule
  \end{tabular}
\end{table}

The remainder of this handbook develops solution methods organized by these classifications; see \cref{ch:first_order} for first-order techniques and \cref{ch:qualitative} for qualitative methods.

% =============================================================================
% INITIAL AND BOUNDARY VALUE PROBLEMS
% =============================================================================

\section{Initial and Boundary Value Problems}
\label{sec:ch01_ivp_bvp}

A differential equation by itself typically admits a family of solutions. Additional conditions—initial or boundary values—restrict the family to a specific solution relevant to the physical or mathematical problem.

\subsection{Initial Value Problems (IVP)}

\begin{definition}[Initial Value Problem]
  An \textbf{initial value problem} (IVP) consists of a differential equation together with conditions specifying the value of the unknown function and/or its derivatives at a single point $x_0$:
  \[
    y^{(n)} = f(x, y, y', \dots, y^{(n-1)}), \qquad
    y(x_0) = y_0,\; y'(x_0) = y_0',\; \dots,\; y^{(n-1)}(x_0) = y_0^{(n-1)}.
  \]
  An $n$-th order IVP requires $n$ initial conditions.
\end{definition}

\begin{workedexample}
  \textbf{IVP examples:}

  \begin{enumerate}
    \item First-order IVP:
      \[
        \frac{\diff y}{\diff x} = 2x, \qquad y(0) = 3.
      \]
      Integrating: $y(x) = x^2 + C$. The condition $y(0) = 3$ gives $C = 3$, so $y(x) = x^2 + 3$.

    \item Second-order IVP:
      \[
        \frac{\diff^2 y}{\diff x^2} = 6x, \qquad y(0) = 1,\; y'(0) = -2.
      \]
      Integrating twice: $y'(x) = 3x^2 + C_1$, $y(x) = x^3 + C_1 x + C_2$. The conditions give $C_1 = -2$ and $C_2 = 1$, so $y(x) = x^3 - 2x + 1$.
  \end{enumerate}
\end{workedexample}

IVPs model \textbf{evolution} problems: given the state of a system at an initial time, predict its future behavior. Typical applications include population growth, radioactive decay, projectile motion, and electrical circuits driven by initial charge/charge rate.

\subsection{Boundary Value Problems (BVP)}

\begin{definition}[Boundary Value Problem]
  A \textbf{boundary value problem} (BVP) consists of a differential equation together with conditions at two or more distinct points:
  \[
    y^{(n)} = f(x, y, y', \dots, y^{(n-1)}), \qquad
    y(a) = \alpha,\; y(b) = \beta, \; \dots
  \]
\end{definition}

\begin{workedexample}
  \textbf{Second-order BVP:}
  \[
    \frac{\diff^2 y}{\diff x^2} = 0, \qquad y(0) = 0,\; y(1) = 1.
  \]
  Integrating: $y(x) = C_1 x + C_2$. The conditions give $C_2 = 0$ and $C_1 = 1$, so $y(x) = x$.
\end{workedexample}

BVPs typically arise in \textbf{steady-state} or \textbf{spatial} problems: heat distribution along a rod, deflection of a beam, or electrostatic potential between electrodes. Unlike IVPs, BVPs may have no solution, a unique solution, or infinitely many solutions.

\subsection{Comparison}

\begin{table}[htbp]
  \centering
  \caption{IVP vs.\ BVP comparison}
  \label{tab:ch01_ivp_bvp}
  \begin{tabular}{@{} l l l l @{}}
    \toprule
    & \textbf{IVP} & \textbf{BVP} & \\
    \midrule
    \textbf{Conditions at:} & Single point $x_0$ & Two or more distinct points \\
    \textbf{Typical problem:} & Time evolution, dynamics & Steady state, spatial distribution \\
    \textbf{Existence:} & Usually guaranteed (Picard--Lindel\"of) & Not guaranteed \\
    \textbf{Uniqueness:} & Usually guaranteed & May fail or have multiple solutions \\
    \textbf{Example:} & $y' = y,\; y(0) = 1$ & $y'' = 0,\; y(0)=0,\; y(1)=1$ \\
    \bottomrule
  \end{tabular}
\end{table}

% =============================================================================
% DIRECTION FIELDS
% =============================================================================

\section{Direction Fields}
\label{sec:ch01_direction_fields}

A direction field provides a geometric picture of the solution family of a first-order ODE without solving it analytically.

\subsection{Construction}

For a first-order ODE $\displaystyle \frac{\diff y}{\diff x} = f(x, y)$, the direction field is constructed as follows:

\begin{enumerate}
  \item Choose a rectangular grid of points $(x_i, y_j)$ in the $xy$-plane.
  \item At each grid point, compute the slope $m_{ij} = f(x_i, y_j)$.
  \item Draw a short line segment centered at $(x_i, y_j)$ with slope $m_{ij}$.
\end{enumerate}

Solution curves are trajectories that are everywhere tangent to the direction field. Reading the field visually reveals qualitative features: equilibrium solutions (horizontal segments), asymptotic behavior, and regions of rapid growth or decay.

\begin{hintbox}
  Look for \textbf{isoslopes}: curves along which $f(x, y)$ is constant. For $\frac{\diff y}{\diff x} = x - y$, isoslopes are the lines $y = x - c$, along which every segment has the same slope $c$.
\end{hintbox}

\subsection{Direction Field Diagram}

The following TikZ figure shows the direction field for $\displaystyle \frac{\diff y}{\diff x} = x - y$ over the region $[-2, 2] \times [-2, 2]$, together with two representative solution curves.

\begin{figure}[htbp]
  \centering
  \begin{tikzpicture}[scale=1.3]
    % Axes
    \draw[->] (-2.3, 0) -- (2.3, 0) node[below right] {$x$};
    \draw[->] (0, -2.3) -- (0, 2.3) node[above left] {$y$};

    % Direction field: dy/dx = x - y
    \foreach \x in {-2,-1.6,-1.2,-0.8,-0.4,0,0.4,0.8,1.2,1.6,2} {
      \foreach \y in {-2,-1.6,-1.2,-0.8,-0.4,0,0.4,0.8,1.2,1.6,2} {
        \pgfmathsetmacro{\slope}{\x - \y}
        \pgfmathsetmacro{\dx}{0.15}
        \pgfmathsetmacro{\dy}{\slope * 0.15}
        % Clamp to avoid excessively long segments
        \pgfmathsetmacro{\len}{sqrt(\dx*\dx + \dy*\dy)}
        \pgfmathsetmacro{\scale}{min(0.35 / max(\len,0.001), 1)}
        \pgfmathsetmacro{\sdx}{\dx * \scale}
        \pgfmathsetmacro{\sdy}{\dy * \scale}
        \draw[gray!70, very thin] (\x-\sdx,\y-\sdy) -- (\x+\sdx,\y+\sdy);
      }
    }

    % Solution curve 1: y = x - 1 + 2*e^{-x}, passing through (0,1)
    \draw[SteelBlue, thick, domain=-2:2, samples=80, smooth]
      plot (\x, {\x - 1 + 2*exp(-\x)});

    % Solution curve 2: y = x - 1 - 2*e^{-x}, passing through (0,-3)
    \draw[SteelBlue!60, thick, domain=-1:2, samples=80, smooth]
      plot (\x, {\x - 1 - 2*exp(-\x)});

    % Equilibrium line y = x (slope = 0 everywhere)
    \draw[ForestGreen!70, dashed, domain=-2:2, samples=40]
      plot (\x, {\x});
    \node[ForestGreen!80, font=\footnotesize] at (1.8, 1.2) {$y=x$};

    % Tick marks
    \foreach \t in {-2,-1,1,2} {
      \draw (\t, 0.05) -- (\t, -0.05) node[below, font=\tiny] {$\t$};
      \draw (0.05, \t) -- (-0.05, \t) node[left, font=\tiny] {$\t$};
    }
  \end{tikzpicture}
  \caption{Direction field for $\frac{\diff y}{\diff x} = x - y$. Blue curves are solution trajectories. The dashed green line $y = x$ is the locus of zero slope (equilibrium for the shifted system).}
  \label{fig:ch01_direction_field}
\end{figure}

\subsection{Sketching Solution Curves}

Given a direction field, individual solution curves can be sketched by hand:

\begin{enumerate}
  \item \textbf{Trace the flow:} Start at a point and follow the segments, drawing a smooth curve tangent to the local arrows.
  \item \textbf{Respect the grid:} The curve should never cross a segment at an angle significantly different from the segment's slope.
  \item \textbf{Identify special features:} Equilibrium points (zero slope), asymptotes, and inflection points often emerge from the field pattern.
\end{enumerate}

\begin{workedexample}
  \textbf{Sketch the solution of $\frac{\diff y}{\diff x} = x - y$ passing through $(0, 1)$.}

  \begin{enumerate}
    \item At $(0, 1)$, the slope is $f(0, 1) = 0 - 1 = -1$. Draw a segment with slope $-1$.
    \item Moving right: at $(1, 0.5)$ (approximately), the slope is $1 - 0.5 = 0.5$. The curve bends upward.
    \item The line $y = x$ is where the slope is zero. For $y > x$, the slope is negative (curves bend down toward $y = x$). For $y < x$, the slope is positive (curves bend up toward $y = x$).
    \item Thus the line $y = x$ acts as an attractor. The solution starting at $(0, 1)$ approaches the line $y = x$ as $x \to \infty$.

  \end{enumerate}

  \textbf{Verification:} The analytic solution is $y(x) = x - 1 + 2e^{-x}$. Indeed, $\lim_{x \to \infty} (y(x) - x) = -1$, and the transient $2e^{-x}$ decays, consistent with the field.
\end{workedexample}

Direction fields also underpin numerical methods such as Euler's method (see \cref{ch:qualitative}).

% =============================================================================
% EXISTENCE AND UNIQUENESS
% =============================================================================

\section{Existence and Uniqueness}
\label{sec:ch01_existence_uniqueness}

A fundamental question before attempting to solve any differential equation is: \emph{does a solution exist?} and \emph{is it unique?} The Picard--Lindel\"of theorem provides the foundational answer for first-order IVPs.

\subsection{The Picard--Lindel\"of Theorem}

\begin{theorem}[Picard--Lindel\"of]
  \label{thm:picard_lindelof}
  Consider the first-order IVP
  \[
    \frac{\diff y}{\diff x} = f(x, y), \qquad y(x_0) = y_0.
  \]
  Let $R = \{(x, y) : |x - x_0| \leq a,\; |y - y_0| \leq b\}$ be a closed rectangle centered at $(x_0, y_0)$ with $a, b > 0$.

  If the following two conditions hold:
  \begin{enumerate}
    \item \textbf{Continuity:} $f(x, y)$ is continuous on $R$;
    \item \textbf{Lipschitz condition:} There exists a constant $L > 0$ such that for all $(x, y_1), (x, y_2) \in R$,
    \[
      |f(x, y_1) - f(x, y_2)| \leq L\,|y_1 - y_2|.
    \]
  \end{enumerate}
  Then there exists an interval $|x - x_0| \leq h > 0$ (with $h \leq a$) on which a \textbf{unique} solution $y = \varphi(x)$ exists.
\end{theorem}

\begin{remark}
  A \textbf{sufficient} (but not necessary) condition for the Lipschitz condition is that $\pd{f}{y}$ exists and is bounded on $R$. In that case, one may take $L = \sup\limits_{(x, y) \in R} \bigl|\pd{f}{y}\bigr|$.
\end{remark}

\subsection{The Lipschitz Condition}

The Lipschitz condition essentially requires that $f$ does not change too rapidly with respect to $y$. Geometrically, it prevents solution curves from diverging too quickly from one another.

\begin{workedexample}
  \textbf{Verify the Lipschitz condition for $f(x, y) = 2xy$ on the rectangle $R = [-1, 1] \times [-1, 1]$.}

  Compute the partial derivative:
  \[
    \pd{f}{y} = 2x.
  \]
  On $R$, $|x| \leq 1$, so $\bigl|\pd{f}{y}\bigr| \leq 2$. Thus $f$ satisfies a Lipschitz condition with $L = 2$ on $R$. By \cref{thm:picard_lindelof}, the IVP $y' = 2xy,\; y(0) = 1$ has a unique solution on some interval around $x = 0$.
\end{workedexample}

\begin{workedexample}
  \textbf{Non-uniqueness when the Lipschitz condition fails.}

  Consider the IVP
  \[
    \frac{\diff y}{\diff x} = y^{2/3}, \qquad y(0) = 0.
  \]
  Here $f(y) = y^{2/3}$. The partial derivative with respect to $y$ is
  \[
    \pd{f}{y} = \tfrac{2}{3}\,y^{-1/3},
  \]
  which is \textbf{unbounded} as $y \to 0$. The Lipschitz condition fails in any rectangle containing $y = 0$.

  Indeed, there are infinitely many solutions:
  \[
    y(x) = 0 \quad \text{(trivial solution)},
  \]
  and for any $c \geq 0$,
  \[
    y(x) =
    \begin{cases}
      0, & 0 \leq x \leq c, \\
      \dfrac{(x - c)^3}{27}, & x > c,
    \end{cases}
  \]
  all satisfy the IVP. The solution branches off from the trivial solution at any chosen point $c$.
\end{workedexample}

\begin{hintbox}
  A quick test for potential non-uniqueness: check whether $\pd{f}{y}$ blows up at or near the initial condition point. If it does, the Lipschitz condition likely fails.
\end{hintbox}

\subsection{Interval of Validity}

\begin{definition}[Interval of Validity]
  The \textbf{interval of validity} (or interval of existence) of a solution $y = \varphi(x)$ to an IVP is the \textbf{largest} open interval $I$ containing $x_0$ on which the solution exists and is differentiable.
\end{definition}

The interval of validity may be restricted by:
\begin{itemize}
  \item Singularities in the coefficients of the equation;
  \item Points where the Lipschitz condition breaks down;
  \item Points where the solution itself becomes unbounded (blow-up).
\end{itemize}

\begin{workedexample}
  \textbf{Find the interval of validity for $y' = y^2,\; y(0) = 1$.}

  This is separable: $\displaystyle \frac{\diff y}{y^2} = \diff x \;\Rightarrow\; -\frac{1}{y} = x + C$. With $y(0) = 1$, we get $C = -1$, so $y(x) = \frac{1}{1 - x}$.

  The solution has a vertical asymptote at $x = 1$. Since the initial point is $x_0 = 0$, the interval of validity is
  \[
    (-\infty, 1).
  \]
  The solution blows up at $x = 1$, so it cannot be extended beyond this point.
\end{workedexample}

\begin{workedexample}
  \textbf{Interval of validity for $y' = \sqrt{y},\; y(0) = 1$.}

  Separating: $\displaystyle \frac{\diff y}{\sqrt{y}} = \diff x \;\Rightarrow\; 2\sqrt{y} = x + C$. With $y(0) = 1$, we get $C = 2$, so $y(x) = \left(\frac{x + 2}{2}\right)^2 = \frac{(x+2)^2}{4}$.

  This solution is defined and differentiable for all $x \in \R$, so the interval of validity is $(-\infty, \infty)$. Note that although the Lipschitz condition fails at $y = 0$ (since $\pd{f}{y} = \frac{1}{2\sqrt{y}}$ is unbounded there), the particular solution passing through $y(0) = 1$ never reaches $y = 0$ for $x > -2$, so uniqueness is preserved along this trajectory.
\end{workedexample}

\section{Summary}
\label{sec:ch01_summary}

\begin{table}[htbp]
  \centering
  \caption{Chapter 1 summary: key concepts in differential equations}
  \label{tab:ch01_summary}
  \begin{tabular}{@{} p{3.8cm} p{5.5cm} @{}}
    \toprule
    \textbf{Concept} & \textbf{Key Definition / Formula} \\
    \midrule
    \textbf{Order} & Highest derivative present (e.g., $y'''$ $\Rightarrow$ 3rd order) \\
    \textbf{Degree} & Power of the highest-order derivative when polynomial in derivatives \\
    \textbf{Linear DE} & $a_n(x)y^{(n)} + \dots + a_1(x)y' + a_0(x)y = g(x)$ \\
    \textbf{Nonlinear DE} & $y$ or derivatives appear to non-integer powers, multiplied together, or inside nonlinear functions \\
    \textbf{Homogeneous (linear)} & $g(x) = 0$ in the linear form \\
    \textbf{IVP} & DE + conditions at a single point: $y(x_0) = y_0, \dots$ \\
    \textbf{BVP} & DE + conditions at two or more distinct points \\
    \textbf{Direction field} & Plot of short line segments with slope $f(x_i, y_j)$ at grid points \\
    \textbf{Picard--Lindel\"of} & Continuity + Lipschitz $\Rightarrow$ local existence and uniqueness \\
    \textbf{Lipschitz condition} & $|f(x, y_1) - f(x, y_2)| \leq L|y_1 - y_2|$; sufficient: $\bigl|\pd{f}{y}\bigr| \leq L$ \\
    \textbf{Interval of validity} & Largest interval containing $x_0$ where the solution exists and is unique \\
    \textbf{Non-uniqueness example} & $y' = y^{2/3},\; y(0) = 0$ admits infinitely many solutions \\
    \bottomrule
  \end{tabular}
\end{table}

The chapters that follow build directly on these foundations. Solution methods for first-order equations are developed in \cref{ch:first_order}; qualitative analysis and numerical methods appear in \cref{ch:qualitative}; and linear second-order theory begins in \cref{ch:second_order_homogeneous}.
