How to get a vector field that maps the slopes of an equation
Hey so I'm reading this article by Chris Hecker where he has an image of a Parabola surrounded by the a vector field of it's derivative:
However he never mentions how exactly he got the vector field equation, and never even states it. He does say he overlayed the vector field of the slopes in Figure 1, by drawing the solution to the开发者_如何学运维 slope equation, dy/dx = 2x, as a short vector at each coordinate on the grid.
How do you create a vector field of the slopes of an equation in the vector field syntax of
V = xi + yjThe Figure title would be clearer if it read:
- The curve
y = x^2
, and the vector fielddy/dx = 2x
for the general casey = x^2 + C
There are three equations at work in the graph above:
y = x^2
- The equation for the parabola drawn - This is the one long solid curvey = x^2 + C
-The equation for all parabolas that fit on the vector field -C
is a constant. This is the equation for all parabolas that fit on that vector fielddy/dx = 2x
The equation for the slope field. - This is the slope or derivative of the both the curve drawn and all the possible curves that can be drawn withy = x^2 + C
for all constantC
s.
Note that C
is a constant, since the derivative of y = x^2 + C
with any C
is 2x
. So the vector field shows how to draw all the different parabolas with different C
s.
So there are two ways to calculate the vector field:
- Iterate over your desired range of x and y and calculate the slope,
dy/dx
-2x
independent ofy
in this case - at each point. This is how the author did it. - Draw a bunch of parabolas by slowly varying
C
iny = x^2 + C
over a desired range of - let's say -x
calculatingy
.
For a differential equation dy/dx = f(x,y) (e.g., dy/dx = 2x in this case, with f(x,y) = 2x), the vector field (F) will be F = i + f(x,y)j (so in your case, F = i + 2x j )
精彩评论