Mathematica - How to Graph Direction Fields of ODEs?

  • Context: Mathematica 
  • Thread starter Thread starter Ascendant0
  • Start date Start date
  • Tags Tags
    Direction Fields Graph
Click For Summary
SUMMARY

This discussion focuses on using Mathematica to graph direction fields for ordinary differential equations (ODEs) using the VectorPlot command. The specific example provided is the first-order differential equation y′ + xy = x. Users expressed confusion regarding the input format for VectorPlot, particularly the significance of the "1" in the command. The conversation emphasizes the importance of understanding slope fields and how to represent them graphically, confirming that at each point (x, y), a vector must be plotted based on the slope derived from the ODE.

PREREQUISITES
  • Understanding of ordinary differential equations (ODEs)
  • Familiarity with Mathematica software
  • Knowledge of vector fields and slope fields
  • Basic calculus concepts, particularly derivatives
NEXT STEPS
  • Learn how to use Mathematica's VectorPlot for different types of ODEs
  • Research the mathematical theory behind slope fields and direction fields
  • Explore advanced features of Mathematica for visualizing differential equations
  • Study examples of direction fields in educational resources like OpenCourseWare
USEFUL FOR

Students and educators in mathematics, particularly those studying differential equations, as well as software users looking to visualize mathematical concepts using Mathematica.

Ascendant0
Messages
177
Reaction score
37
So, I'm working on ODE at this point, and unfortunately I don't have the time to learn all of the Mathematica input for at least a few months. But, I was hoping someone could tell me how to graph direction fields of ODEs, either with the Mathematica input or free-form?

Looking through the Mathematica site, it looks like VectorPlot or VectorPlot3D is one of the two commands I'd be looking to use, but the two pages I found on the site show information that went over my head. I don't know how to enter in what I'm looking to do.

Basically, I want to be able to take something like y′+xy=x, and create a graph of the direction field within a given region. I wanted to take a little time to do this for multiple equations (including some of the ones I'm seeing in the OpenCourseWare lectures), so that I can get a better idea of the general type of field for certain types of ODEs (without having to take the time to put them together myself). Any help here would be greatly appreciated.
 
Physics news on Phys.org
Ascendant0 said:
I don't know how to enter in what I'm looking to do.
Is this what you want?

1721206597868.png
 
  • Like
Likes   Reactions: Ascendant0
renormalize said:
Is this what you want?

View attachment 348450
Yes, that's the type of thing I'm looking to do. How would I go about plugging a differential equation into a vector plot like that?
 
Ascendant0 said:
Yes, that's the type of thing I'm looking to do. How would I go about plugging a differential equation into a vector plot like that?
Post #2 is the vector plot of the 1rst-order differential equation you gave: y′+xy=x.
 
  • Like
Likes   Reactions: Ascendant0
renormalize said:
Post #2 is the vector plot of the 1rst-order differential equation you gave: y′+xy=x.
Oh, ok I got you. So it automatically assumes it as an equation for y' without having to plug it into the input. Thank you, I appreciate the help
 
renormalize said:
Post #2 is the vector plot of the 1rst-order differential equation you gave: y′+xy=x.
I did have one other question in regards to that input. The "1" in front of the "x - xy", is that for "first order differential", or something else?
 
Ascendant0 said:
I did have one other question in regards to that input. The "1" in front of the "x - xy", is that for "first order differential", or something else?
Do you understand the basic idea of plotting a "direction-" or a "slope-" field? Can you describe how you'd do it by hand with pencil and paper (before worrying about how it's done in a particular software like Mathematica)?
 
renormalize said:
Do you understand the basic idea of plotting a "direction-" or a "slope-" field? Can you describe how you'd do it by hand with pencil and paper (before worrying about how it's done in a particular software like Mathematica)?
Yea, I have all that down. You plug in x, plug in y, then the answer gives you the slope at that location.

Like ##dy/dx = 2x^2 - 3y^3 ##; at x = 2 and y = 3, ##dy/dx = -73## (which is the slope)

If I didn't even know how to do that yet, it wouldn't be making much sense to be asking how to put it into Mathematica, lol.

But anyway, still not sure what the "1" in the front of the equation in VectorPlot means. What I do know is if I plug "y" in there instead of the 1, I get vectors in a circle. Looked around on the web, and I don't see anything from Mathematica that clarifies it for me.
 
Ascendant0 said:
Yea, I have all that down. You plug in x, plug in y, then the answer gives you the slope at that location.

Like ##dy/dx = 2x^2 - 3y^3 ##; at x = 2 and y = 3, ##dy/dx = -73## (which is the slope)

If I didn't even know how to do that yet, it wouldn't be making much sense to be asking how to put it into Mathematica, lol.
You apparently don't understand because that's not the way to plot a direction-field. At each point ##x,y## you must to plot a vector, not a number like "##-73##". Please read https://en.wikipedia.org/wiki/Slope_field to learn how.
 
  • #10
renormalize said:
You apparently don't understand because that's not the way to plot a direction-field. At each point ##x,y## you must to plot a vector, not a number like "##-73##". Please read https://en.wikipedia.org/wiki/Slope_field to learn how.
How are you going to plot a direction field without knowing what the slope is at any given location? Did I say "draw a -73 there"? No, but without the slope, you most certainly aren't going to draw the direction field, which I'm well more than aware on how to draw. What I don't know is a specific part of the VectorPlot command above, and this is become completely tangential and irrelevant to what I'm trying to learn. I've plotted direction fields multiple times now by hand, just wasn't sure with VectorPlot, but I think I've figured it out between your previous help and testing various equations. I appreciate it.
 
  • Like
Likes   Reactions: renormalize

Similar threads

  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K