# CPT 03: Direction Fields

Author: John J Weber III, PhD Corresponding Textbook Section:

• Section 1.3 – Direction Fields

Expected Educational Results

• Objective 3–1: I can distinguish between autonomous equations and non-autonomous equations.

• Objective 3–2: I can identify equilibrium solutions to ordinary differential equations.

• Objective 3–3: I can identify stability of equilibrium solutions to ordinary differential equations.

• Objective 3–4: I can sketch typical solution(s) to ordinary differential equations.

• Objective 3–5: I can use technology to sketch direction fields to ordinary differential equations.

## Differential Equations

### Separable ODEs

#### Definition: Separable DE

Separable DE: A DE is separable if the DE, ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=f\left(x,y\right)$$y^{\,\prime}=f(x,y)$, can be written as a product ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=f\left(x\right)g\left(y\right)$$y^{\,\prime}=f(x)g(y)$.

NOTE: The derivative ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }\left(x\right)$$y^{\,\prime}(x)$ may be a function of more than one variable $f\left(x,y\right)$$f(x,y)$.

#### Definition: Autonomous DE

Autonomous DE: A DE is autonomous if the DE is a function of only the dependent variable, i.e., ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=f\left(y\right)$$y^{\,\prime}=f(y)$.

NOTE: All autonomous equations are separable. The method of partial fractions is needed to solve autonomous equations.

### Solutions to ODEs

Definition: A solution to an ODE are equations for curves that when substituted into the ODE results in a mathematically true statement.

#### Investigation 01

Let ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }\left(x\right)=x{y}^{2}+y-x$$y^{\,\prime}(x)=xy^2+y-x$.

1. What does ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }\left(x\right)$$y^{\,\prime}(x)$ describe about $y\left(x\right)$$y(x)$. Explain.

2. Is $y\left(x\right)$$y(x)$ a linear function? Explain.

#### Investigation 02

Let ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }\left(x\right)=x{y}^{2}+y-x$$y^{\,\prime}(x)=xy^2+y-x$. Find the values for ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }\left(x\right)$$y^{\,\prime}(x)$ at the following points $\left({x}_{i},{y}_{i}\right)$$(x_i,y_i)$, i.e., find $f\left({x}_{i},{y}_{i}\right)$$f(x_i,y_i)$:

1. $\left(0,0\right)$$(0,0)$

2. $\left(-2,1\right)$$(-2,1)$

3. $\left(-1,1\right)$$(-1,1)$

4. $\left(-\frac{1}{2},-\frac{2}{3}\right)$$\left(-\frac{1}{2},-\frac{2}{3}\right)$

#### Investigation 03

From your knowledge of algebra, identify a function whose $y$$y$-values never change. Explain.

#### Investigation 04

From your knowledge of calculus, what do you know about the derivative of the function that you identified in the previous Investigation? Explain.

### Equilibrium Solutions

#### Definition: Equilibrium Solution

Equilibrium Solution: Equilibrium solutions are $y$$y$-values, ${y}_{i}$$y_i$, such that $f\left({y}_{i}\right)=0$$f(y_i)=0$.

#### Stability of Equilibrium Solutions

• An equilibrium solution is stable if and only if solutions near them converge to $y={y}_{i}$$y=y_i$.

• An equilibrium solution is semi-stable if:

• solutions near $y={y}_{i}$$y=y_i$ converge to $y={y}_{i}$$y=y_i$ for $y>{y}_{i}$$y>y_i$ and diverge for $y<{y}_{i}$$y, OR

• solutions near $y={y}_{i}$$y=y_i$ converge to $y={y}_{i}$$y=y_i$ for $y<{y}_{i}$$y and diverge for $y>{y}_{i}$$y>y_i$.

• An equilibrium solution is unstable if and only if solutions are neither stable solutions nor semi-stable solutions.

## Direction Fields

#### Definition: Direction Fields

Direction Fields: A direction field of a DE is a graphical representation, using vectors, of the solutions to a first-order DE.

#### Definition: Slope Fields

Slope Fields: A slope field of a DE is a graphical representation, using line segments, of the solutions to a first-order DE.

#### Definition: Phase Lines

Phase Lines: A phase line of an autonomous DE is a graphical representation of the equilibrium solutions to autonomous DEs.

#### Sketching Slope Fields

The key to constructing direction fields and phase lines is to understand what ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }$$y^{\,\prime}$ describes about $y$$y$ by answering the following questions:

• Is the DE autonomous? Explain.

• Identify the equilibrium solutions to the DE. Explain.

• Classify the equilibrium solutions as stable, semi-stable, or unstable. Explain.

• Sketch several solutions to completely describe solutions to the DE. Explain.

#### Investigation 05

Sketch the directions fields (and phase lines, where appropriate) for the following:

1. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=y\left(y-2{\right)}^{2}\left(y-4\right)$$\displaystyle y^{\,\prime}=y(y-2)^2(y-4)$

2. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }={y}^{3}-2{y}^{2}$$\displaystyle y^{\,\prime}=y^3-2y^2$

3. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=\mathrm{sin}\left(y\right)$$\displaystyle y^{\,\prime}=\sin{(y)}$

4. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=1-{e}^{y}$$\displaystyle y^{\,\prime}=1-e^y$

5. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=\left(y-1{\right)}^{2}\left(y+2{\right)}^{2}{e}^{-2y}$$\displaystyle y^{\,\prime}=(y-1)^2(y+2)^2e^{-2y}$

6. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=x\left(y-3\right)\left(1+y\right)$$\displaystyle y^{\,\prime}=x(y-3)(1+y)$

7. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }={x}^{2}{y}^{2}\left(y-4\right)$$\displaystyle y^{\,\prime}=x^2y^2(y-4)$

8. ${y}^{\phantom{\rule{0.167em}{0ex}}\prime }=xy\left(y+2\right)\left(y-4\right)$$\displaystyle y^{\,\prime}=xy(y+2)(y-4)$

### Verify Slope Fields

Example: Plot the slope field for ${y}^{\prime }=y\left(y-2{\right)}^{2}\left(y-4\right)$$y^{\prime}=y(y-2)^2(y-4)$

#### Mathematica

xxxxxxxxxx1(* Example, plot the slope field for y'=y(y-2)^2(y-4) *)2
3(* Plot the direction field *)4VectorPlot[{1, y (y - 2)^2 (y - 4)}, {x, -10, 10}, {y, -10, 10}]5
6(* Typically, StreamPlot is easier to use *)7StreamPlot[{1, y (y - 2)^2 (y - 4)}, {x, -10, 10}, {y, -10, 10}]8
9(* NOTE: the range of values for x and y can be changed as needed *)  

#### Python

1# Import the needed packages2import numpy as np3import matplotlib.pyplot as plt4#5# Set up the mesh grid; change as needed6Y, X = np.mgrid[-3:7:100j, -5:5:100j]7#8# Set up the autonomous DE as parametric equations9# Change V as needed ** is exponentiation10U = X11V = Y*(Y-2)**2*(Y-4)12#13# Set up streamplot and plot14fig, ax = plt.subplots()15ax.streamplot(X, Y, U, V)16#17# Show the plot18plt.show()

NOTE: Later in the course, we will see how to create phase planes for multivariate DEs.