Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168757
Image: ubuntu2004
# # dy/dx = x - y # from pylab import * def fn(x, y): return x - y def isocline_fn(c, x): return x + c def exact_fn(c, x): return (x - 1 + c * exp(-x)) def xcomp(fn): return 1 / sqrt(1 + fn**2) def ycomp(fn): return fn / sqrt(1 + fn**2) xr = arange( 0,5,0.3) yr = arange( 0,5,0.3) figure() X = zeros([len(xr), len(yr)]) Y = zeros([len(xr), len(yr)]) U = zeros([len(xr), len(yr)]) V = zeros([len(xr), len(yr)]) for x in range(0, len(xr)): for y in range(0, len(yr)): X[x][y] = xr[x] Y[x][y] = yr[y] U[x][y] = xcomp(fn(xr[x], yr[y])) V[x][y] = ycomp(fn(xr[x], yr[y])) Q = quiver(X, Y, U, V) # isocline xr = arange(0,5,0.1) for c in arange(-3,7,0.5): yy = isocline_fn(c, xr) # plot(xr, yy) # exact xr = arange(0,5,0.1) for c in arange(-100,100,6): yy = exact_fn(c, xr) plot(xr, yy) axis([0,5,0,5]) savefig('df-3.png')