Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The command desolve_system_rk4 returns a list of lists of the form [time pt, x value, y value]. You can use a list comprehension as below to pull out coordinate pairs. Then, you can plot using the line command.

x,y,t=var('x y t')
P=desolve_system_rk4([x*(1-y),-y*(1-x)],[x,y],ics=[0,0.5,2],ivar=t,end_points=20)
tx = [[q[0],q[1]] for q in P]
ty =  [[q[0],q[2]] for q in P]
line(tx)+line(ty,color='red')