2
$\begingroup$

I have found links for plot the direction field of a differential equation. For example:

How can I plot the direction field for a differential equation?

And:

Plotting the direction field of a differential equation

But when I am teaching differential equations in the spring 2015, these are not the forms I would prefer. I am struggling mightily with the VectorScale options unitlen, aratio, sfun, so much so that I fear my students would not be able to handle these.

The equation I am dealing with is:

$$ \frac{dy}{dt}=e^{-t}-2y$$

If I do the following:

VectorPlot[{1, Exp[-t] - 2 y}, {t, -2, 3}, {y, -1, 2}, Axes -> True]

I get the following image:

enter image description here

Now, the difficulty here is that some of the arrows overlap, some are too small to interpret. I've spent about 4 hours this morning playing with the VectorScale command, trying to understand unitlen, a ratio, and sfun, but minimal success. So far, here is the best image I have come up with. I normalized all the vectors so they had length one, then I set the VectorScale to 0.03.

VectorPlot[Normalize[{1, Exp[-t] - 2*y}], {t, -2, 3}, {y, -1, 2}, VectorScale -> .03, Axes -> True ]

Here is the resulting image:

enter image description here

This is the one I like the best so far, but I am just a beginner. If folks on this site have better suggestions so that I can easily help students who have never used Mathematica before, I'd love to hear them.

$\endgroup$
5
  • $\begingroup$ Mark McClure has done some nice things. E.g. mathematica.stackexchange.com/questions/43155/… $\endgroup$
    – Michael E2
    Commented Nov 22, 2014 at 21:09
  • $\begingroup$ Related: 43478 $\endgroup$
    – C. E.
    Commented Nov 22, 2014 at 21:37
  • $\begingroup$ @Pickett I can't imagine a better answer than Mark's answer to 43478. I suppose one could replace the 0.03 by 0.5 divided by the number of VectorPoints (15), or deal with the slightly off lengths due to the AspectRatio. $\endgroup$
    – Michael E2
    Commented Nov 22, 2014 at 21:53
  • 1
    $\begingroup$ @MichaelE2 I agree with you so much that I initially (before I commented) voted to close this as a duplicate, but my insecurity got the better of me and I retracted my vote so now I've lost my voting rights :) $\endgroup$
    – C. E.
    Commented Nov 22, 2014 at 22:05
  • $\begingroup$ @Pickett No big deal. Good find, although I realize you may have had an advantage. :) $\endgroup$
    – Michael E2
    Commented Nov 22, 2014 at 22:40

0

Browse other questions tagged or ask your own question.