# Direction Fields in Mathematica

1. Jan 19, 2007

### steelphantom

I just picked up a copy of Mathematica through Penn State, and I'm trying to figure out how to plot a direction field of a differential equation. For example, I have the differential equation $$dv/dt = 32 - 8v$$

I've found this page on Wolfram's site that shows you how to do it, but in the line
Code (Text):
In[3]:= field=PlotVectorField[{1,Last[eqn]},{x,-2,2},{y[x],-2,2}]
kind of confuses me with the arguments that are used. I understand the second two sets of arguments (x and y arguments), but what's up with the first one {1, Last[eqn]}? Where did the 1 and Last come from?

Also, there's another page on Wolfram's site that displays the following as the format for the PlotVectorField function:
Code (Text):
PlotVectorField[f, {x, x0, x1, (xu)}, {y, y0, y1, (yu)}, (options)]
What do (xu) and (yu) represent? The rest of it I understand (I think! ). Sorry for all of these questions. I'm definitely a Mathematica n00b and I think it's going to take a little getting used to. Thanks!

2. Jan 19, 2007

### Crosson

First of all I suggest you always use the built in Mathematica documentation untill you know lots and lots of what's in there.

The following code will do what you want:
Code (Text):

<< GraphicsPlotField

(* The one is the t_component of the vector field and Last[
Eqn] gives the right_hand_side of and equation i.e. the v_component. I put \
this in directly *)

Field = PlotVectorField[{1, 32 - 8v}, {t, 0, 10}, {v, -5, 5}]

(* Here is some more code that will impose a solutions on the vector field assuming that you also ran the code above*)

Show[Field, Plot[Evaluate[v[t] /. NDSolve[{v'[t] == 32 - 8v[t], v[0] == -6}, \
v, {t, 0, 20}]], {t, 0,
10}, PlotStyle -> Red, PlotRange -> {{0, 10}, {-5, 5}}]]

Last edited: Jan 20, 2007