Draw a slope field
A differential equation of the form
where \(F(x,y)\) is an expression in \(x\) and \(y\), gives the slope of a solution at each point of its graph. A solution on an open interval is a differentiable function \(y\) with \(y'(x)=F\big(x,y(x)\big)\) for every \(x\) in the interval (topic 7.2). A slope field draws these slopes as short segments, so it shows the shape of the solutions without a formula for them.
This topic computes and draws the segments, finds where they are flat, and matches a field with its equation.
The segment at a point
The slope field of dy/dx = (x + y)/2 for x from −4 to 4 and y from −3.6 to 3.6, with a segment at every point whose coordinates are whole numbers from −3 to 3. The segments are flat on a dashed orange line y = −x. They rise above the line and fall below it, more steeply farther from it. An orange dot at (3, −1), which can be dragged to any point of the grid, carries an orange segment of slope 1, and the numbers under the figure show the substitution that gives the slope. One button draws a solution curve through the point, which passes through the point along the orange segment and follows the segments of the field on both sides. Another button turns every segment to the slope of dy/dx = (x + y)/y. The x-axis then becomes a red dashed line with no segments, and a point moved onto it has no segment.
Suppose that the graph of a solution passes through the point \(\cy{(a,b)}\), so that \(y(a)=b\). The equation then gives the slope of the graph at that point:
The slope depends only on the point, so every solution through \(\cy{(a,b)}\) has the same slope there. The slope field of the equation, which some books call a direction field, draws a short segment centered at each point of a grid. The segment at \(\cy{(a,b)}\) has slope \(\cy{F(a,b)}\), so it lies along the tangent line of every solution through that point.
Figure 1 shows the slope field of \(\frac{dy}{dx}=\frac{x+y}{2}\). To find the slope at a point, substitute its first coordinate for \(x\) and its second for \(y\). At the orange dot \((3,-1)\), the slope is \(\frac{3+(-1)}{2}=1\). Drag the dot, or use the sliders. The orange segment turns to the slope at each new point, and the numbers under the figure show the substitution.
Use the button under Figure 1 to show a solution through the point. The curve passes through the point along the orange segment, and on both sides it follows the segments of the field.
The slope fixes how the segment is drawn. Its sign gives the orientation: a positive slope rises to the right, a negative one falls, and a slope of 0 is flat. Its size \(|F(a,b)|\) gives the steepness, and a larger size gives a steeper segment. When both axes use the same scale, as in every figure here, slopes of 1 and \(-1\) make 45° angles with the axes. A segment with \(|F(a,b)|<1\) is then flatter than 45°, and one with \(|F(a,b)|>1\) is steeper.
The argument needs \(F(a,b)\) to be a number. Use the button under Figure 1 to divide by \(y\) instead of 2. The new right side \(\frac{x+y}{y}\) has no value where \(y=0\), so the red dashed \(x\)-axis has no segments. Move the point onto the axis. Its segment disappears, and no solution can pass through it, because the slope \(F(a,0)\) that it would need does not exist. Then use the button again to divide by 2.
Where the slope is zero
The points where \(F(x,y)=0\) form the zero-slope set of the equation, and every segment on it is flat. In Figure 1, \(\frac{x+y}{2}=0\) where \(y=-x\), so the zero-slope set is the dashed orange line. A solution whose graph meets this line has a horizontal tangent at that point.
A constant function \(y=c\) has derivative 0. It is therefore a solution on an interval when, and only when, \(F(x,c)=0\) for every \(x\) in the interval. Its graph is then a horizontal line of flat segments, and it is called a constant solution, or an equilibrium solution.
Conversely, suppose that the graph of a solution lies in the zero-slope set over an interval. Its derivative \(F\big(x,y(x)\big)\) is then 0 throughout that interval, so the solution is constant there, a corollary of the Mean Value Theorem (topic 6.8). A solution can therefore run along the zero-slope set only where that set is a horizontal line. In Figure 1, every segment on the dashed line is flat, but the line itself falls with slope \(-1\). It is therefore not the graph of a solution.
The slope field of dy/dx = (y − 1)/2 for x from −3.6 to 3.6 and y from −2.5 to 3.5. Every row of segments has one slope: flat on the dashed orange line y = 1, rising above it and falling below it. Orange segments mark the row y = 2, where every slope is 1/2, and the column x = 3, where the slopes run from −3/2 at the bottom to 1 at the top. A button turns every segment to the slope of dy/dx = (x − 1)/2. The flat segments then move from the line y = 1 to the vertical line x = 1, and the dashed line moves with them, always through the point (1, 1). Every column now has one slope, the orange column has slope 1 throughout, and the slopes on the orange row run from −2 at the left to 1 at the right.
Figure 2 shows the slope field of \(\frac{dy}{dx}=\frac{y-1}{2}\). Here \(F(x,1)=0\) for every \(x\), so the dashed orange line \(y=1\) is the graph of a constant solution.
Patterns across a field
A row of a field is a horizontal line of segments, and a column is a vertical one. In Figure 2, the orange segments mark the row \(y=2\) and the column \(x=3\). Along a row only \(x\) changes, and the slope \(\frac{y-1}{2}\) does not depend on \(x\), so the segments on the row are parallel. Those on the column differ.
Use the button under Figure 2 to change the equation to \(\frac{dy}{dx}=\frac{x-1}{2}\). The segments on the column become parallel, and those on the row differ. The flat segments now lie on the vertical line \(x=1\). No function has a vertical line as its graph, so this line is not the graph of a solution.
In general, if \(F\) depends only on \(y\), as in \(\frac{dy}{dx}=g(y)\), every row has one slope, and the equation is called autonomous. If \(F\) depends only on \(x\), as in \(\frac{dy}{dx}=h(x)\), every column has one slope, because along a column only \(y\) changes.
If \(F\) depends on both variables, neither pattern holds. The segments are still parallel along any curve on which \(F\) has one value, and such a curve is called an isocline. In Figure 1, \(\frac{x+y}{2}=k\) on the line \(y=2k-x\), so every segment on that line has slope \(k\). The zero-slope set is the isocline for \(k=0\).
To match a field with one of several equations, first compare the segments along a row and along a column. Then find the flat segments and the regions where the segments rise or fall. Last, test a point where the remaining equations differ, because two equations can agree at one point.
Example 1
Calculate slopes at supplied points
Consider the differential equation \(\dfrac{dy}{dx}=\dfrac{x^2-1}{y}\). Find the slope of its slope field at each of the points \((-2,1)\), \((1,5)\), \((0,-2)\) and \((4,0)\).
Solution
The right side is defined wherever \(y\ne 0\). At each point, substitute the first coordinate for \(x\) and the second for \(y\):
At \((4,0)\) the denominator is 0, so the equation gives no slope. The field has no segment there, although some fields draw a vertical one where only the denominator is 0.
Example 2
Match a slope segment to a point
Consider the differential equation \(\dfrac{dy}{dx}=x-\dfrac{y}{2}\). Sketch a slope field for the equation at the nine points whose coordinates are \(-1\), 0 or 1.
Axes with −1 and 1 marked on each, and an orange segment centered at each of the nine points whose coordinates are −1, 0 or 1. From left to right, the slopes are −3/2, −1/2 and 1/2 on the row y = 1, −1, 0 and 1 on the row y = 0, and −1/2, 1/2 and 3/2 on the row y = −1. The segment at the origin is flat, the segments at (−1, 0) and (1, 0) make 45 degree angles with the axes, and the steepest segments are at (−1, 1), falling, and at (1, −1), rising.
Solution
The right side is defined at every point. Substituting the coordinates of each point gives these slopes:
Each segment rises where its slope is positive and falls where it is negative, and the segment at the origin is flat. The segments at \((1,0)\) and \((-1,0)\) have slopes 1 and \(-1\), so they make 45° angles with the axes. The slopes \(\pm\frac32\) give steeper segments than these, and the slopes \(\pm\frac12\) give flatter ones. Figure 3 shows the sketch.
Example 3
Locate zero-slope sets
Consider the differential equation \(\dfrac{dy}{dx}=(y+1)\left(y-x^2\right)\). Describe all points in the \(xy\)-plane at which the slope is 0. Which part of this set is the graph of a solution?
Solution
The right side is defined at every point. A product is 0 when, and only when, one of its factors is 0, so the slope is 0 where
The zero-slope set is the line \(y=-1\) together with the parabola \(y=x^2\). On the line, the right side is \(0\cdot\left(-1-x^2\right)=0\) for every \(x\), so the constant function \(y=-1\) is a solution.
Every segment on the parabola is flat too, but the function \(y=x^2\) has derivative \(2x\). To be a solution, it would need \(2x=0\) on an interval, yet \(2x=0\) only at \(x=0\). A solution that meets the parabola has a horizontal tangent at that point, but no solution runs along the parabola. Only the line \(y=-1\) is the graph of a solution.
Example 4
Recognize patterns across a field
Figure 4 shows the slope field of one of the following differential equations. Which one? (A) \(\frac{dy}{dx}=x^2\) (B) \(\frac{dy}{dx}=y^2\) (C) \(\frac{dy}{dx}=x+y\) (D) \(\frac{dy}{dx}=xy\)
A slope field for x from −2.7 to 2.7 and y from −2.4 to 2.4, with a segment every 0.5 units in each direction. The segments are flat along both axes. They rise where x and y have the same sign and fall where the signs differ, and they become steeper away from the axes. Orange segments mark the row y = 1, which fall to the left of the y-axis and rise to its right, and the column x = 1, which fall below the x-axis and rise above it.
Solution
All four right sides are defined at every point. On the orange row \(y=1\), the segments fall to the left of the \(y\)-axis and rise to its right. Equation B gives one slope on each row, so it does not fit. On the orange column \(x=1\), the segments fall below the \(x\)-axis and rise above it. Equation A gives one slope on each column, so it does not fit either.
The flat segments lie along both axes, where equation D is 0, but equation C is 0 only on the line \(y=-x\). Equation D is also positive where \(x\) and \(y\) have the same sign and negative where their signs differ, as in the field. The field belongs to equation D.
Each example is one of the four skills of topic 7.3 in Which & Why: AP Calculus.