Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
166 views
# example of turning vector field var('x','y') # matrix eigenvalue/eigenvector pairs are -1, [1,0] and -2, [1,-1/2] M = matrix([[-1,2],[0,-2]]) system = M*vector([x,y]) M.eigenvalues() M.eigenvectors_right() # plot vector field and eigenvectors ("eigendirections") p = plot_vector_field(M*vector([x,y]),(x,-1.6,1.6),(y,-1.6,1.6),aspect_ratio=1) p+= plot(-1/2*x,(x,-1.6,1.6),color="red") p+= plot(0*x,(x,-1.6,1.6),color="red") # show trajectories from a bunch of initial conditions t = srange(0,50,.1) for ic in zip(srange(-1,1,.2),srange(-1,1,.2)): sol = desolve_odeint(M*vector([x,y]),dvars=[x,y],ics=ic,times=t) p += list_plot(sol,plotjoined=True) show(p)
(x, y) [-1, -2] [(-1, [ (1, 0) ], 1), (-2, [ (1, -1/2) ], 1)]