Register to reply

Direction Fields in Mathematica

by steelphantom
Tags: direction, fields, mathematica
Share this thread:
Jan19-07, 08:17 PM
P: 159
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 [tex]dv/dt = 32 - 8v[/tex]

I've found this page on Wolfram's site that shows you how to do it, but in the line
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:
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!
Phys.Org News Partner Science news on
Bees able to spot which flowers offer best rewards before landing
Classic Lewis Carroll character inspires new ecological model
When cooperation counts: Researchers find sperm benefit from grouping together in mice
Jan19-07, 11:19 PM
P: 1,295
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:
(* Loads the Package *)

<< Graphics`PlotField`

(* 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}}]]

Register to reply

Related Discussions
Magnitude & Direction of electric fields? Introductory Physics Homework 4
Magnitude and Direction of Electric Fields Introductory Physics Homework 11
Differential Equations: Direction Fields Differential Equations 2
Emf, current, electric fields...what direction is everything moving? Introductory Physics Homework 4
Please help me with magnetic fields - how can i find its direction? Introductory Physics Homework 7