importnumpyasnpfromscipy.linalgimportexpmimportmatplotlib.pyplotaspltdefsetarrow(s,nrow,skip,x):narrows=x.shape[1]//2foriinrange(narrows):cols=slice(2*i,2*i+2)arrowloc=np.vstack((x[nrow,cols],x[nrow+skip,cols]))# Generate data for the boundary of the planar dynamicsx=np.linspace(-5,5,101)y=x**2/4quad=np.column_stack((x,y))lines=np.array([[-5,0,0,-7,0,0.75],[5,0,0,0,0,10]])# Neutral centertheta=np.linspace(0,2*np.pi,101)xcenter=np.column_stack((np.cos(theta),np.sin(theta),0.5*np.cos(theta),0.5*np.sin(theta)))# Stable nodex0_list=np.array([[1,1],[-1,1],[-1,-1],[1,-1]])nts=101time=np.linspace(0,15,nts)A=np.array([[-1,-2],[0,-1]])xnode=[]forx0inx0_list:x=np.zeros((2,nts))fori,tinenumerate(time):x[:,i]=expm(A*t)@x0xnode.append(x.T)xnode=np.hstack(xnode)# Stable starxstar=np.zeros([2,8])xstar[0,:]=[1,1,-1,1,-1,-1,1,-1]# Save data to .dat file with format '%f'withopen("phasebound.dat","w")asf:np.savetxt(f,quad,fmt='%f',header="quad")f.write("\n\n")np.savetxt(f,lines,fmt='%f',header="lines")f.write("\n\n")np.savetxt(f,xcenter,fmt='%f',header="xcenter")f.write("\n\n")np.savetxt(f,xnode,fmt='%f',header="xnode")f.write("\n\n")np.savetxt(f,xstar,fmt='%f',header="xstar")# Plot for interactive modeplt.show(block=False)