from scitools.std import * def nonlinearSystem(u0,v0,T,dt): """Numerical solution with implicit scheme of u'(t)=-v(t)^3, u(0)=u0, v'(t)=u(t)^3, v(0)=v0, for 0eps: A=matrix([[1, 3*dt*pow(xy[1,0],2)],[-3*dt*pow(xy[0,0],2), 1]]) xy=xy-A.I*matrix([[f],[g]]) f=xy[0,0]+dt*pow(xy[1,0],3)-a g=xy[1,0]-dt*pow(xy[0,0],3)-b return xy