Direction Fields in Mathematica


by steelphantom
Tags: direction, fields, mathematica
steelphantom
steelphantom is offline
#1
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 Phys.org
Lemurs match scent of a friend to sound of her voice
Repeated self-healing now possible in composite materials
'Heartbleed' fix may slow Web performance
Crosson
Crosson is offline
#2
Jan19-07, 11:19 PM
P: 1,294
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