Plotting ODEs, Isoclines using Python
I am looking for a Python package that will allow me to plot something similar to the Java applet seen below:
http://math.mit.edu/mathlets/mathlets/isoclines/
Does anyone know any ODE plot开发者_高级运维ting packages for this? I can code something from scratch using Numpy, Matplotlib, but I wanted to ask around first.
Thanks,
I wrote something like this, it seems to work for y'=y^2-x
from pylab import *
xmax = 4.0
xmin = -xmax
D = 20
ymax = 4.0
ymin = -ymax
x = linspace(xmin, xmax, D)
y = linspace(ymin, ymax, D)
X, Y = meshgrid(x, y)
deg = arctan(Y**2 - X)
QP = quiver(X,Y,cos(deg),sin(deg))
show()
Sage will do this:
x,y = var("x y")
eq = y^3-3*y-x
p = implicit_plot(eq==0,(x,-4,4),(y,-4,4))
p += plot_slope_field(eq, (x,-4,4),(y,-4,4), headlength=1e-8)
p.show(aspect_ratio=1)
although it's simply wrapping matplotlib functionality for the graphics. (To be perfectly honest, the matplotlib wrapping isn't as good as it could be yet, which often causes me headaches.)
精彩评论