## The direction field

The solutions of differential equation (5.2) are curves in the [ , , ]-space, which are given by [ , , ]. The direction field is given by the tangent vectors to the solution curves, i.e., by the vectors [ , , ]. Note that you can derive the direction field by means of the right hand side of the differential equation, so you do not need to know the solutions explicitly. In general the explicit dependency on time is omitted and the solutions and the direction field are only plotted in the [ , ]-plane. So, in fact, the projection on the [ , ]-plane is being drawn. This plane is also called the phase plane or state space (the state of the system at time is given by [ , ]). The projected solution is also called an integral curve. In a given point [ , ] of the state space, the direction vector can be calculated by using the differential equations given. In equation (5.2), the direction vector for the point [ , ] = [1,2] is given by [ , ] = [5*1-2*2, 7*1-4*2] = [1,-1]. The direction field is obtained by determining the direction vector in every point of the state space. To draw a direction field in MATLAB, you first need to indicate the points in the [ , ]-plane where you want to draw the direction vector. The command:

>> [X,Y] = meshgrid(-1:0.1:1,-2:0.2:2)

produces a matrix for which every row is equal to the vector -1:0.1:1 and a matrix for which every column is equal to the vector -2:0.2:2. By combining these matrices elementwise, you obtain grid points [x,y], where traverses the vector -1:0.1:1 and traverses the vector -2:0.2:2, i.e., the points [ , ]. The matrices and can now be used to perform calculations in the grid points. For example, and calculates the components [U,V] of the direction field in every grid point for equation 5.2. To draw the direction field in a number of grid points, you can use the MATLAB command quiver. The command:

>> quiver(X,Y,U,V)

draws the vectors with components [ , ] in the points [ , ]. The vectors are scaled automatically. As a consequence of this, sometimes the direction field becomes somewhat unclear. In that case, reducing the number of grid points often clarifies the direction field.

Esteur 2010-03-22