Next: Higher level DEtools routines: Up: Plotting direction fields and Previous: Examples

## Direction fields only: fieldplot

This command is not specifically for direction fields, but is for plotting two dimensional vector fields. However, this is exactly what we need to plot the direction field for a two dimensional autonomous system, since the vector field is tangent to the solutions of equation (2). That is, this vector field is the direction field.

Since a trick is needed to get fieldplot to plot direction fields for a single first order differential equation, we start with our our two-dimensional model, equation (4). The commands below will plot the direction field for and . Note that the plots package has to be loaded first, but you only need to do this once per session.

```  > with(plots):
```

```  > fieldplot([y,-4*x],x=-2..2,y=-2..2);
```

The first argument to fieldplot is always the vector field. It has to be in the form of a Maple list, that is, a sequence of comma-separated items enclosed in square brackets. Order is important in a list, so you should always put first and second.

To plot the direction field for a single first order differential equation, we introduce a dummy variable s and write equation 1 as the two dimensional system

With the initial condition s(0) = 0, note that the first equation can be solved to give s(t) = t, so the solution to equation (5) is really the same as the solution to equation (1).

Using this trick, we can plot the direction field for our example, equation 3 with the following command.

```  > fieldplot([1,sin(x^2)],s=0..5,x=-2..2);
```

William W. Farr
Thu Oct 24 13:33:53 EDT 1996