MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: entering problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35342] Re: entering problem
  • From: Murray Eisenberg <murraye at attbi.com>
  • Date: Tue, 9 Jul 2002 06:47:52 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200207080720.DAA19828@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

Here's a start, using the Graphics`PlotField` standard add-on package.  

You need to load the package, then manufacture a vector field whose plot
is the "slope field" (what you call "vector flow diagram").  To do the
latter, let me separately define the function giving the right-hand side
of the ODE; you don't really have to do that, but could instead directly
use as the first argument to PlotVectorField the right-hand side of my
definition of f.

   << Graphics`PlotField`

   f[t_, y_] := {1, 1/y}

   field = PlotVectorField[f[t, y], {t, 0, 3}, {y, 0.05, 3}];

I gave a name to the graphics result just in order to re-display the
field below along with the graph of one solution.  First, find a general
solution:

   soln = First @ DSolve[{y'[t] == 1/y[t], y[0] == 1}, y[t], t]
{y[t] -> Sqrt[2]*Sqrt[1/2 + t]}


   grf = Plot[y[t] /. soln, {t, 0, 3}];

Now combine the plot with the field:

  Show[grf, field];

Note that PlotVectorField does not always give quite the result you
might want, since the vector lengths are scaled with respect to the
magnitude of the actual vectors.  You might want just a "direction
field" in which all arrows have the same length.  You can produce such a
graphic by using the ScaleFunction and ScaleFactor options to
PlotVectorField.  For example:

   field = PlotVectorField[f[t, y], {t, 0, 3}, {y, 0.05, 3}, 
      ScaleFunction -> (1 &), ScaleFactor -> 0.175];



Mark Zellmer wrote:
> 
> How do I enter the following problem to graph a vector flow diagram?
> y'=1/y
> 
> I've tried several different ways but keep getting errors.

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.       
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street
Amherst, MA 01375


  • Prev by Date: RE: Plotting problem
  • Next by Date: RE: Strategy for overly long computations?
  • Previous by thread: entering problem
  • Next by thread: Re: entering problem