Re: directionfields from StreamPlot looks different from
- To: mathgroup at smc.vnet.net
- Subject: [mg100468] Re: [mg100444] directionfields from StreamPlot looks different from
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Fri, 5 Jun 2009 03:00:36 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200906040732.DAA11830@smc.vnet.net>
- Reply-to: murray at math.umass.edu
You're not. For the "direction field" of a 1-dimensional ordinary
differential equation y' == f[t, y], the vector field you want to plot
is {1, f[t,y]}. So...
streams =
StreamPlot[{1, t^2 - y}, {t, -4, 4}, {y, -2, 10},
StreamStyle -> Directive[Orange]];
sol = Table[NDSolve[{y'[t] == t^2 - y[t], y[0] == y0}, y[t],
{t, -4, 4}], {y0, 0, 6, 0.5}];
solutionCurves =
Plot[y[t] /. sol, {t, -4, 4}, PlotRange -> {{-4, 4}, {-2, 10}}];
Show[{solutionCurves, streams}
Note that you do not need any parentheses around t^2. And in the current
version of Mathematica, you no longer need to wrap y[t]/.sol with
Evaluate -- unless you would like the curves automatically to be given
different colors.
sean_incali at yahoo.com wrote:
> I don't think I'm using StreamPlot properly.
>
> Consider the following non-autonomous ODE
>
> y'[t] == (t^2) - y[t]
>
> Solutions for various ICs can be viewed by the following.
>
> sol= Table[NDSolve[{y'[t] == (t^2) - y[t], y[0] == y0}, y[t], {t, -4,
> 4}], {y0, 0, 6, 0.5}];
>
> Plot[Evaluate[y[t] /. sol], {t, -4, 4}, PlotRange -> {{-4, 4}, {-2,
> 10}}]
>
> Shouldn't Vector fields be similar to the solutions above? If I plot t
> on x-axis vs. t^2-y on y axis...
>
> VectorPlot[{t, (t^2) - y}, {t, -4, 4}, {y, -2, 10}]
>
> StreamPlot[{t, (t^2) - y}, {t, -4, 4}, {y, -2, 10}]
>
> I don't get similar results...
>
> What is the reason for this?
>
> Thanks much in advance
>
> Sean
>
>
>
>
--
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 fax 413 545-1801
Amherst, MA 01003-9305
- References:
- directionfields from StreamPlot looks different from solution
- From: sean_incali@yahoo.com
- directionfields from StreamPlot looks different from solution