Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168753
Image: ubuntu2004
# # dy/dx = 0.2 * x * y # from pylab import * def fn(x, y): return 0.2 * x * y def isocline_fn(c, x): return c / (0.2 * x) def exact_fn(c, x): return exp(0.1*(x**2 + c)) 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.1,5,0.1) for c in arange(0,10,0.25): yy = isocline_fn(c, xr) plot(xr, yy) # exact xr = arange(0,5,0.1) for c in arange(-10,10,3): yy = exact_fn(c, xr) # plot(xr, yy) axis([0,5,0,5]) savefig("df-2.png")