Loading [MathJax]/jax/output/HTML-CSS/jax.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

Homework 1b copy

( \newcommand{\kernel}{\mathrm{null}\,}\)

Prerequisite: The derivative of a function evaluated at a point = slope of the tangent line at that point.

This homework set contains two problems, each with multiple parts. Problem 1 is worth 4 points, while problem 2 is worth 1 point.

 

Direction fields consist of small portions of tangent lines drawn at several points. 

For example, the direction field for y=(y1)(y+2) is drawn below.

import matplotlib.pyplot as plt
import numpy as np

# Set up the grid for plotting
t = np.linspace(-2, 2, 20)
y = np.linspace(-3, 2, 20)
T, Y = np.meshgrid(t, y)

# Compute the slopes of the direction field
dY = (Y - 1) * (Y + 2)
dT = np.ones_like(dY)

# Normalize the vectors
M = np.hypot(dT, dY)
dT /= M
dY /= M

# Plot the direction field
plt.figure(figsize=(10, 10))
plt.quiver(T, Y, dT, dY, color='blue')
plt.title("Direction Field for $y' = (y-1)(y+2)$")
plt.xlabel('t')
plt.ylabel('y')
plt.xlim([-2, 2])
plt.ylim([-3, 2])
plt.grid()
plt.show()

 

Direction fields can be used to draw the graphs of solutions to differential equations. Several solutions are drawn on the direction field below.

import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp

# Set up the grid for plotting
t = np.linspace(-4, 4, 20)
y = np.linspace(-4, 4, 20)
T, Y = np.meshgrid(t, y)

# Compute the slopes of the direction field
dY = (Y + 1) * (Y - 2)
dT = np.ones_like(dY)

# Normalize the vectors
M = np.hypot(dT, dY)
dT /= M
dY /= M

# Plot the direction field
plt.figure(figsize=(10, 10))
plt.quiver(T, Y, dT, dY, color='Black', alpha=0.6)
plt.title("Direction Field for $y' = (y+1)(y-2)$")
plt.xlabel('t')
plt.ylabel('y')
plt.xlim([-4, 4])
plt.ylim([-4, 4])
plt.grid()

# Function representing the differential equation
def dydt(t, y):
    return (y + 1) * (y - 2)

# Initial conditions for the solutions and additional lines
initial_conditions = [1, -1, -2, 2, 2.1, 1.9]
colors = ['red', 'blue', 'green', 'orange', 'purple', 'brown']

# Solve the differential equation for each initial condition and plot the solutions
for y0, color in zip(initial_conditions, colors):
    sol = solve_ivp(dydt, [-4, 4], [y0], t_eval=np.linspace(-4, 4, 200))
    plt.plot(sol.t, sol.y[0], label=f'y0={y0}', color=color)

# Show the plot
plt.show()

 

Notice how these solutions stay tangent to the tangent lines. When drawing a solution starting at a point (a,b),you can think of the path a boat would take if placed at this point and if the tangent lines indicated the direction of water flow.

A solution to a differential equation is an equilibrium solution if it is a constant solution, y=C. The graph of y=C is a horizontal line. Observe in the direction field above that y=(y1)(y+2) has two equilibrium solutions y=1 and y=2.

If y=C is a solution, then it should satisfy the differential equation when we plug it in. In particular, if y=C, then y=0. Thus to determine if y=f(t,y) has an equilibrium solution, plug in y=0 and solve for constant solutions (if any exist).

Most differential equations do not have equilibrium solutions; however, we will mostly look at differential equations of the form y=f(y) where the slope y depends only on y. Many, but not all, of these will have equilibrium solutions.

To summarize:

  • An equilibrium solution is the constant solution, y=C (and thus y=0).
  • To find equilibrium solutions, plug in y=0, and solve for y. An equilibrium solution exists if and only if y=C is a solution for some constant C.
  • A differential equation can have 0, 1, or multiple equilibrium solutions.

HW Problem 1: Draw direction fields by hand for the following differential equations. For these questions, y=f(y), and thus the slope only depends on y. Thus if the slope of the tangent line at (t0,y0) is m, then the slope at (t,y0) is also m for all values of t. Thus if you draw a small portion of a tangent line at (t0,y0), you can quickly draw several other ones with the same slope at (t,y0) for various values of t (but at the same height y0). For each of the following problems: 

  • Find the equilibrium solutions.
  • For each of the equilibrium solutions, y=Ci, draw small portions of tangent lines at the points (t,Ci) for several values of t. Note that since y(t)=Ci, then y=0, and thus the slope of the tangent line at (t,Ci) is zero for all t.
  • You should draw a sufficient number of slopes so that one can determine the behavior of various solutions to the differential equation. Thus you should draw at least two different slopes above and below an equilibrium solution and at least 3 different slopes between any two equilibrium solutions as well as several slopes parallel to these slopes.
  • Draw solutions that pass through (0, -1), (0, 0), (0, 1), (0, 2), and (0, 3).
  • Determine the long-term behavior for the solution passing through (t0,y0). How does this behavior depend on t0? How does this behavior depend on y0?

HW Problem 1a.    y=y
HW Problem 1b.    y=y(y2)
HW Problem 1c.    y=y(2y)
HW Problem 1d.    y=y(2y)2

HW Problem 2: In calculus, you solved differential equations of the form y=f(t). We will look at one such example, so that you can compare the above problems to one from calculus.

HW Problem 2a: Draw the direction field for y=t. Note this direction field does not have an equilibrium solution. If you plug in y=0, you get t=0, but this is not a horizontal line, y=C, and is thus not as equilibrium solution. If t=0, the slope is zero, but these slopes occur along the yaxis (where t=0). Thus you cannot draw a horizontal line connecting these slopes. Draw several slopes along the yaxis as well as several slopes for positive and negative t values. Note the slopes depend only on t and not y for this calculus problem.

HW Problem 2b: Draw several solutions to the differential equation y=t on the direction field you drew for problem 2a. Note if fracdydt=t, then dy=tdt. Since this is a calculus problem, we can integrate both sides to determine y: y=12t2+C. Observe that the solutions that you drew are of the form: y=12t2+C where each solution is shifted vertically from the other solutions. This is very different than the solutions you drew in problem 1. Thus solutions for differential equations of the form y=f(t,y) can look very different than calculus 1 differential equations y=f(t). However, when you solve any first order differential equation, one constant C will appear in the solution, but not usually as a simple shift of +C as you had in calculus 1.


 

Direction fields can look very interesting. Below are some additional examples.

The differential equation y=y2+1 does not have an equilibrium solution:

import matplotlib.pyplot as plt
import numpy as np

# Set up the grid for plotting
t = np.linspace(-2, 2, 20)
y = np.linspace(-2, 2, 20)
T, Y = np.meshgrid(t, y)

# Compute the slopes of the direction field
dY = Y**2 + 1
dT = np.ones_like(dY)

# Normalize the vectors
M = np.hypot(dT, dY)
dT /= M
dY /= M

# Plot the direction field
plt.figure(figsize=(10, 10))
plt.quiver(T, Y, dT, dY, color='black', alpha=0.6)
plt.title("Direction Field for $y' = y^2 + 1$")
plt.xlabel('t')
plt.ylabel('y')
plt.xlim([-2, 2])
plt.ylim([-2, 2])
plt.grid()
plt.show()

 

 

The differential equation y=sin(t)sin(y) has infinitely many equilibrium solutions:

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

import matplotlib.pyplot as plt
import numpy as np

# Set up the grid for plotting
t = np.linspace(-4, 4, 20)
y = np.linspace(-4, 4, 20)
T, Y = np.meshgrid(t, y)

# Compute the slopes of the direction field
dY = np.sin(T) * np.sin(Y)
dT = np.ones_like(dY)

# Normalize the vectors
M = np.hypot(dT, dY)
dT /= M
dY /= M

# Plot the direction field
plt.figure(figsize=(10, 10))
plt.quiver(T, Y, dT, dY, color='black', alpha=0.6)
plt.title("Direction Field for $y' = \sin(t) \sin(y)$")
plt.xlabel('t')
plt.ylabel('y')
plt.xlim([-4, 4])
plt.ylim([-4, 4])
plt.grid()
plt.show()
import matplotlib.pyplot as plt
import numpy as np

# Set up the grid for plotting
t = np.linspace(-4, 4, 20)
y = np.linspace(-4, 4, 20)
T, Y = np.meshgrid(t, y)

# Compute the slopes of the direction field
dY = np.sin(T) * np.sin(Y)
dT = np.ones_like(dY)

# Normalize the vectors
M = np.hypot(dT, dY)
dT /= M
dY /= M

# Plot the direction field
plt.figure(figsize=(10, 10))
plt.quiver(T, Y, dT, dY, color='black', alpha=0.6)
plt.title("Direction Field for $y' = \sin(t) \sin(y)$")
plt.xlabel('t')
plt.ylabel('y')
plt.xlim([-4, 4])
plt.ylim([-4, 4])
plt.grid()
plt.show()

 

 

The direction field for y=ty is drawn below. Observe that the solutions to y=ty are semi-circles. In this class, we will assume that our solutions are always functions and thus satisfy the vertical line test. Thus a solution to y=ty corresponds to either the top half or the bottom half of a circle.

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

import matplotlib.pyplot as plt
import numpy as np

# Set up the grid for plotting
t = np.linspace(-2, 2, 20)
y = np.linspace(-2, 2, 20)
T, Y = np.meshgrid(t, y)

# Compute the slopes of the direction field
dY = T / Y
dT = np.ones_like(dY)

# Normalize the vectors
M = np.hypot(dT, dY)
dT /= M
dY /= M

# Plot the direction field
plt.figure(figsize=(10, 10))
plt.quiver(T, Y, dT, dY, color='black', alpha=0.6)
plt.title("Direction Field for $y' = t/y$")
plt.xlabel('t')
plt.ylabel('y')
plt.xlim([-2, 2])
plt.ylim([-2, 2])
plt.grid()
plt.show()
import matplotlib.pyplot as plt
import numpy as np

# Set up the grid for plotting
t = np.linspace(-2, 2, 20)
y = np.linspace(-2, 2, 20)
T, Y = np.meshgrid(t, y)

# Compute the slopes of the direction field
dY = T / Y
dT = np.ones_like(dY)

# Normalize the vectors
M = np.hypot(dT, dY)
dT /= M
dY /= M

# Plot the direction field
plt.figure(figsize=(10, 10))
plt.quiver(T, Y, dT, dY, color='black', alpha=0.6)
plt.title("Direction Field for $y' = t/y$")
plt.xlabel('t')
plt.ylabel('y')
plt.xlim([-2, 2])
plt.ylim([-2, 2])
plt.grid()
plt.show()

 

*Optional*: You can draw your own direction fields using the code in this notebook

To summarize:

  • Direction field = slope field = graph of dydt in the t,y plane (small portions of tangent lines).
  • Direction fields allow one to draw graphs of solutions to a first order differential equation without solving the differential equation
  • Thus one can use the slope field to determine behavior of y(t) including as t±.
  • Make sure you understand equilibrium solutions (constant solutions, y=C, horizontal lines) due to their importance in applications and understanding other solutions.

Warning: **Direction fields can be misleading.** We will discuss this in sections 2.4 and 2.7.

 


Homework 1b copy is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

  • Was this article helpful?

Support Center

How can we help?