Artificial Intelligence 🤖
Differential equations
Ordinary differential equations
Introduction to ODEs
Visualisation

Visualisation

Analytic techniques for the solution of ODEs give a closed form solution describing the dependent variable as the independent variable varies. However, a lot of information may be obtained by visualising ODEs. This section focuses on the approximate representation of solutions using the direction field.

Direction fields

Recall the definition of tangent lines: if y=f(x)y=f(x) defines a function of xx whose derivative, dy/dxd y / d x exists on an interval I:a<x<b\mathcal{I}: a<x<b (where, aa and bb are constants), then dy/dxd y / d x gives the slope of the graph of this function at each point whose xx coordinate is in I\mathcal{I}. A geometric view of the DE is given by direction fields which help us visualise the solutions to the DE and their late-time behaviour.

To illustrate these ideas, we consider the example of a falling object. Consider a particle of mass m kgm \mathrm{~kg} falling under the action of gravity. It is assumed that only two forces act on the subject: air resistance (F1)\left(F_{1}\right) and gravity (F2)\left(F_{2}\right), as shown in Fig. 11.2.

The total force, FF, acting on the object is given by the sum of the two forces,

F=(F1)+F2F=\left(-F_{1}\right)+F_{2}

note, here we chose the upward direction to be negative, F1-F_{1} while the downward direction is taken to be positive, +F2+F_{2}. By Newton's second law, the total force acting on the object is directly proportional to the acceleration, aa, produced by it,

F=ma.F=m a .

We model the two forces F1F_{1} and F2F_{2} as follows. We take the air resistance to be proportional to the velocity of the object, vv, which in turn is taken to be a function of time, tt, i.e. v=v(t)v=v(t). Using cc is as the constant of proportionality, the air resistance may be modelled by

F1=cv(t)F_{1}=c v(t)

while the gravitational force is given by,

F2=mgF_{2}=m g

where gg is the gravitational acceleration. To make calculations in this section easier, gg is approximated to 10 ms210 \mathrm{~ms}^{-2}. Equations (11.13) - (11.15) may be combined to give,

ma=cv(t)+mg.m a=-c v(t)+m g .

With acceleration represented as the rate of change of velocity with time, a=dv/dta=d v / d t, Eq. (11.16) may be expressed in terms of a differential equation for v(t)v(t),

dvdt=mgcv(t)m\frac{d v}{d t}=\frac{m g-c v(t)}{m}

Suppose m=2 kgm=2 \mathrm{~kg} and c=4kgs1c=4 \mathrm{kgs}^{-1}, Eq. (11.17) becomes,

dvdt=102v(t)\frac{d v}{d t}=10-2 v(t)

Figure 11.2: Labelled force balance for the falling object; F1F_{1} denotes air resistance and F2F_{2} is the force under gravity.

Equation (11.18) represents a first-order, ordinary differential equation for v(t)v(t) and note that the dependence of tt (the independent variable) only appears implicitly through v(t)v(t). Now, any solution to this ODE, has 102v10-2 v as the gradient at a value of vv. We illustrate this by choosing a series of values for vv and simply drawing arrows at each vv - along the tt-axis - with slope (102v)(10-2 v).

Suppose that at some point, the velocity of the object reaches 5 ms15 \mathrm{~ms}^{-1}; plugging this value in Eq. (11.18) yields

dvdt=0\frac{d v}{d t}=0

This implies that, for all time tt for which the velocity of the object reaches 5 , the acceleration is zero. In a vtv-t graph, zero acceleration is depicted by a zero-slope gradient shown by arrows drawn horizontally. This is shown in Fig. 11.3 for 0t100 \leq t \leq 10 and 0v100 \leq v \leq 10. Let us now assume that at some time tt, the velocity reaches 6 ms16 \mathrm{~ms}^{-1}; in Eq. (11.18), this

Figure 11.3: Direction arrows corresponding to Eq. (11.18) when v=5 ms1v=5 \mathrm{~ms}^{-1}.

gives a gradient of -2 , indicating that at v=6v=6, the velocity of the object is decreasing. Adding this information to Fig. 11.3, we have arrows depicting a negative gradient equal to -2 when v=6v=6. Again note that dv/dt=2d v / d t=-2 when v=6v=6 for all values of tt. For v=4v=4, dv/dt=2d v / d t=2 for all values of tt. Figure 11.4 adds to Fig. 11.3 showing the direction field for v=6v=6 (red arrows) and v=4v=4 (green arrows).

Figure 11.4: Direction field corresponding to ODE (11.18) for v=5v=5 (blue arrows) and v=6v=6 (red arrows), and v=4v=4 (green arrows).

Continuing this way, i.e. by plugging in values for vv to determine the slope, gives us a way to visualise the direction field within the entire interval of interest which, in turn, helps us understand how the solutions to the ODE behave. Figure 11.5 shows the direction field generated for various values of vv. Note that the direction fields in both panels, (a) and (b) are equivalent; arrowheads are not always included on the line segments. When omitted, the plot is referred to a slope field since it lacks direction.

(a)

(b)

Figure 11.5: Direction field corresponding to ODE (11.18). The slopes of the line segments are identical in both panels; the arrows in panel (a) indicate slope and direction while in panel (b), the line segments merely indicate slope.

How can we use a plot showing the direction field to extract information on the behaviour of the ODE solutions? The arrows we have been drawing so far represent the tangents to the solutions to the differential equation (11.18). For instance, suppose we are given that, at t=0t=0, the velocity of the object is v=4v=4 (this is the initial condition). At (t,v)=(0,4)(t, v)=(0,4), we know that the solution [i.e. v(t)v(t) ] is increasing since the gradient is positive. At (0,4)(0,4), we have a single point on the vtv-t plot; as time evolves, we follow the direction of the arrows and, as the gradient becomes less and less positive, the solution becomes less and less steep. This is shown in Fig. 11.6; starting with the IC at (0,4)(0,4) and following the direction of the arrows, we trace the green solution on the vtv-t plot. The graphical view of the solution to a DE using the direction field is known as an integral curve. Figure 11.6 shows two more integral curves. The black solution corresponds to the IC (0,5)(0,5); following the zero-slope arrows, we stay at v=5v=5 for all time. The red solution corresponds to the IC (0,6)(0,6); immediately after t=0t=0, the solution for vv decreases fast (indicated by the steep negative gradient) and slows down as it approaches v=5v=5.

Figure 11.6: Direction field for ODE (11.18) with three integral curves (solutions): the red, black, and green curves correspond to initial conditions given at t=0t=0 and v=6,5v=6,5, and 4 , respectively.

Solving differential equations exactly or even numerically is generally not an easy task. Therefore, having a method to visualise the solution like, for example, using the direction field is useful. An ODE given in terms of an equation, for instance

dydx=f(x,y)\frac{d y}{d x}=f(x, y)

is an analytic representation. A direction field, is the geometric representation of the ODE. Moreover, the analytic representation of a solution is again given in terms of an equation, for instance in explicit form,

y=g(x),y=g(x),

while the integral curve is the geometric analogue.

Isoclines

In the example of the falling object, the resulting ODE was simple enough such that the direction field was easily drawn by plugging in various values of vv in the ODE. Now, take a more general form of a first-order ODE, for example

dydx=f(x,y)\frac{d y}{d x}=f(x, y)

where y=y(x)y=y(x) and xx is the independent variable. Assuming that f(x,y)f(x, y) is a complicated function of xx and yy then the method we used in Subsec. 11.2.1 to obtain the direction field would prove to be tedious. The method of isoclines gives a quick way to obtaining the direction field. An isocline is a set of points (a line or a curve) where all direction field arrows that lie on it have the same slope.

The method

Algebraically, we obtain the isoclines corresponding to an ODE by solving the following equation

dydx=f(x,y)=c\frac{d y}{d x}=f(x, y)=c

where cc is some constant. We show how to obtain the isoclines with the help of the following ODE,

dydx=xy\frac{d y}{d x}=-\frac{x}{y}

Note that in Eq. (11.20), the independent variable is explicitly present as opposed to the ODE from the falling object example.

Step 1:

Set the differential equation given in Eq. (11.20) to some constant, say cc

dydx=xy=c\frac{d y}{d x}=-\frac{x}{y}=c

which, rearranged, gives

y=xc or cy=x.y=\frac{-x}{c} \text { or } c y=-x .

The equations in (11.22) define the isoclines. Please note that these are not solutions to the ODE.

Step 2:

Draw several isoclines by choosing different values for the constant cc. For example, in Eqs. (11.22), for c=1c=1, the isocline is given by the line y=xy=-x [see Fig. 11.7(a)].

Step 3:

On each isocline, draw line segments (or arrows) along the line, each having a slope cc. In Fig. 11.7(b), the isocline y=xy=-x is generated with c=1c=1 and therefore the line segments drawn on the line are of slope 1.191 .^{19} All line segments drawn on the line have the same slope (a slope of 1 ). Apart from the isocline y=xy=-x, there exist no other regions with a slope field equal to 1.

Step 3 is repeated with different values of cc thus finding all the regions of equal slope, gradually generating the direction field corresponding to the differential equation. A value of c=1c=-1 yields the isocline y=xy=x on which the line segments have a slope equal to c=1c=-1

19{ }^{19} Note that, in this case, the isocline and the line segments are perpendicular to each other because the product of their slopes is -1 .

(a)

(c)

(b)

(d)

Figure 11.7: (a) Isocline corresponding to c=1c=1 in Eq. (11.22) with equation y=xy=-x. (b) Isocline [from panel (a) and line segments of slope c=1c=1. (c) Additional isocline for c=1c=-1 (equation of line: y=xy=x ) and line segments (blue) with slope c=1c=-1. (d) Direction field to ODE (11.20) and several isoclines generated with different values of cc

[see Fig. 11.7(c)]. Figure 11.7(d) shows the direction field in 5x5-5 \leq x \leq 5 and yx5y \leq x \leq 5 (note that only a few isoclines are shown here).

Visualising the solution

We can obtain insight on the behaviour of the ODE solutions, once we have the direction field by following the arrows as done in the falling object example. Integral curves are drawn by choosing a particular point in the xyx-y plane, keeping in mind that the integral curve (i.e. the solution) is tangent to the line segments/arrows. We can probably see from Fig. 11.7(d), that the solution forms a circle; see Fig. 11.8 for a particular solution (actually two solutions) to the ODE shown together with the direction field. From Definition 11.1, a particular solution is valid if it is continuous and satisfies the initial condition. The derivative is undefined at y=0y=0 [see Eq. (11.21)]; hence the solution shown in Fig. 11.8 is made up of two semi-circles. The first one (shown in red) is defined for y>0y>0 and was generated using (1,2)(1,2) as the IC while the second one (shown in black) is defined for y<0y<0 and was generated using (1,2)(1,-2) as the IC. Which part is to be accepted as the solution to an IVP ultimately depends on the initial conditions.

Figure 11.8: Direction field to ODE (11.21) and the corresponding integral curves. The red solution is generated using (1,2)(1,2) as the IC while the black solution is generated using (1,2)(1,-2) as the IC.

Horizontal & vertical isoclines

If we were to use the method of isoclines for the falling object example earlier in this chapter, then all isoclines would be horizontal. In fact, any ODE of the form,

dydx=f(y)( no explicit x-dependence in f)\frac{d y}{d x}=f(y)(\text { no explicit } x \text {-dependence in } f)

where y=y(x)y=y(x), has horizontal isoclines. The slope of the line segments on the isoclines of course depends on the corresponding value of cc.

Any ODE of the form,

dydx=f(x)( no explicit y-dependence in f)\frac{d y}{d x}=f(x)(\text { no explicit } y \text {-dependence in } f)

where, again, y=y(x)y=y(x) has vertical isoclines.

The shape of the isoclines corresponding to the differential equations that take the more general form,

dydx=f(x,y)\frac{d y}{d x}=f(x, y)

depend on the actual form of the original equation.